Skip to content

fix push "false" blocking replace in hx-location and hx-replace-url - #4121

Open
rameel wants to merge 1 commit into
bigskysoftware:devfrom
rameel:fix-blocking-replace
Open

rameel wants to merge 1 commit into
bigskysoftware:devfrom
rameel:fix-blocking-replace

Conversation

@rameel

@rameel rameel commented Oct 7, 2026

Copy link
Copy Markdown

Description

v2.0.11 regressed the documented HX-Location combination of disabling push and using replace:

HX-Location: {"path":"/test2", "push":"false", "replace":"true"}

The request and swap succeed, but history is not updated at all. The same happens with attributes:

<div hx-push-url="false" hx-replace-url="true">...</div>

Cause: #4093 (fix for #3966) removed the if (pushUrl === 'false') pushUrl = null normalization added in #3741 and reintroduced a late path === 'false' guard. A truthy "false" wins over replace again, and the late guard then returns {}.

Fix in determineHistoryUpdates:

push / replace 2.0.10 2.0.11 this PR
"false" / "true" replace nothing replace
false / "true" replace replace replace
hx-push-url="false" on boosted link push nothing nothing

Side effect: etc.push/etc.replace now fall back to the inherited attributes with ?? instead of ||. A boolean false passed to htmx.ajax (or in HX-Location with an explicit source) now disables an inherited hx-push-url/hx-replace-url instead of being ignored. This matches how HX-Location already treats false (#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-url on a regular element and on a boosted link; boosted link with hx-replace-url="false" still pushes.
  • test/core/headers.js: HX-Location with push as "false" and false plus replace; boosted source with push/replace disabled updates nothing.
  • test/core/api.js: push: false / replace: false override inherited attributes.
  • test/util/util.js: recordHistoryUpdates() helper that records htmx:pushedIntoHistory / htmx:replacedInHistory events, so tests can tell push from replace.

Checklist

  • I have read the contribution guidelines
  • I have targeted this PR against the correct branch (master for website changes, dev for
    source changes)
  • This is either a bugfix, a documentation update, or a new feature that has been explicitly
    approved via an issue
  • I ran the test suite locally (npm run test) and verified that it succeeded

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant