Repository navigation
Conversation
bigskysoftware#4093 removed the "false" normalization for push, so a truthy "false" won over replace again and the history update was dropped. Normalize "false"/false for push and replace, use ?? so an explicit false overrides an inherited hx-push-url/hx-replace-url, and keep the boosted fallback disabled when push is explicitly disabled.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
v2.0.11 regressed the documented
HX-Locationcombination of disabling push and using replace:The request and swap succeed, but history is not updated at all. The same happens with attributes:
Cause: #4093 (fix for #3966) removed the
if (pushUrl === 'false') pushUrl = nullnormalization added in #3741 and reintroduced a latepath === 'false'guard. A truthy"false"wins overreplaceagain, and the late guard then returns{}.Fix in
determineHistoryUpdates:'false'andfalseare normalized tonullfor bothpushandreplacebefore choosing between them, so a disabled push no longer blocks replace (restores fix hx-location to handle replace #3741).path === 'false'guard is removed since it is no longer reachable."false"/"true"false/"true"hx-push-url="false"on boosted linkSide effect:
etc.push/etc.replacenow fall back to the inherited attributes with??instead of||. A booleanfalsepassed tohtmx.ajax(or inHX-Locationwith an explicitsource) now disables an inheritedhx-push-url/hx-replace-urlinstead of being ignored. This matches howHX-Locationalready treatsfalse(#3740) and how htmx 4 behaves.Corresponding issue: #3966 (regression introduced by #4093)
Testing
There were no tests for push being disabled together with replace, which is why this regression went unnoticed. Added:
test/attributes/hx-replace-url.js:hx-push-url="false"+hx-replace-urlon a regular element and on a boosted link; boosted link withhx-replace-url="false"still pushes.test/core/headers.js:HX-Locationwithpushas"false"andfalseplusreplace; boosted source with push/replace disabled updates nothing.test/core/api.js:push: false/replace: falseoverride inherited attributes.test/util/util.js:recordHistoryUpdates()helper that recordshtmx:pushedIntoHistory/htmx:replacedInHistoryevents, so tests can tell push from replace.Checklist
masterfor website changes,devforsource changes)
approved via an issue
npm run test) and verified that it succeeded