hasHeader() tested a regex against getAllResponseHeaders() output, which
false-positively matched any header containing an htmx header name as a
substring — e.g. X-HX-Trigger or HX-Trigger-User. After the false-positive,
xhr.getResponseHeader('HX-Trigger') returned null, and handleTriggerHeader
crashed on triggerBody.indexOf('{').
Refactors hasHeader(xhr, regex) → hasHeader(xhr, name), using
getResponseHeader(name) !== null as the check. This is the exact check
the 12 call sites need, eliminates the substring-match class of bug, and
removes a layer of indirection (no more regex construction or
getAllResponseHeaders() scan per check).
Adds a regression test with X-HX-Trigger: foo that previously crashed
inside handleTriggerHeader.
Fixes#527. Addresses @1cg's suggestion in that thread.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
fix: remove empty class attribute left behind after htmx operations
After htmx removes its utility classes (swapping, settling, request),
elements are left with an empty class="" attribute if they had no other
classes. This happens because doSettle and the request indicator cleanup
use raw classList.remove instead of removeClassFromElement, which
already handles empty class attribute removal.
Replace classList.remove with removeClassFromElement at three sites:
- swappingClass removal (line 1978)
- settlingClass removal in doSettle (line 1999)
- requestClass removal from indicators (line 3415)
Fixes#1701
Supersedes #2683
* add pushUrl option
* Remove duplicate save to history
* Improve pushUrl and hx-location url handling
* Add replace option to api as well
* minor wording change
* push headers support true
* roll back anchor support for header base paths except for true case
* add selectOOB and simplify ajax helper
* Remove refactor
* reverse order of push/replace
---------
Co-authored-by: MichaelWest22 <michael.west@docuvera.com>
* Update Node Versions and types to fix latest tsc upgrade issues
* fix playwright only test filtering that has broken from playwright browser updates
---------
Co-authored-by: MichaelWest22 <michael.west@docuvera.com>
(cherry picked from commit 56299971ce)
* Update Node Versions and types to fix latest tsc upgrade issues
* fix playwright only test filtering that has broken from playwright browser updates
---------
Co-authored-by: MichaelWest22 <michael.west@docuvera.com>
* Handle not preventing link when inside htmx enabled element
* Simplify shouldCancel and pass in eltToListenOn to solve from: issue without regressions
* move regex to local variable format
* Added regression test for swap=outerHTML unexpected behavior, checked it failes, implemented initial fix in htmx.js that makes (all) test(s) run and pass.
* Renamed variable in my regression test to be more clear.
* I noticed I wasn't using the copies of the attributes I introduced.Tests were passing and I know why, though. This means I miss one more regression test for the bug in cloneAttributes.
* Added one more regression test for the fix in cloneAttributes.
* Made preservation of htmx- prefixed classes more robust in cloneAttributes after I noted they could as well be removed by mergeTo.setAttribute in the second forEach loop.
* Started as a typo-fix, ended up renaming regression tests to be more explicit.
* Started as a typo-fix, ended up renaming regression tests to be more explicit.
* Removed space that I accidentally added before.
* Applied changes as requested by MichaelWest22.
---------
Co-authored-by: Matteo Smaila <matteo.smaila@314softwaresolutions.com>
Co-authored-by: 1cg <469183+1cg@users.noreply.github.com>
* Move History storage to sessionStorage and history path to window
* Fix type warnings
* Revert currentPathForHistory to move it to its own PR
* fix test
* Improve history support and events
* Improve history event overrides
* Improve history support and events
* Improve history event overrides
* Update Documentation of new event changes
* Add event testing for updated events
* update event doco and rename to historyElt to be consistent
* Improve history support and events
* Improve history event overrides
* Update Documentation of new event changes
* Add event testing for updated events
* update event doco and rename to historyElt to be consistent
* Fix loc coverage test coverage
* Standardize history restore functions to use proper htmx swap functions
* Add test for hx-history-elt attribute
* Fix broken merge conflict resolution
* move delay and view transitions to inside swap function
* Fix indenting and add tests
* move delay and view transitions to inside swap function
* Fix indenting and add tests
* revert rollback of feat: handle 'unset'for HX-Reselect in swap function
* Fixes issue 1537 - OOB does not escape query selector
* Adds test cases for oob swaps where the id contains special characters
* Updated oob multiple elements with the same ID test
* fix(issue-1537): resolved conflicts with master
* fix(issue-1537): fixed codestyle issues
---------
Co-authored-by: Fraser Chapman <fraser.chapman@gmail.com>
Co-authored-by: David Martiník <david.martinik@powerflow.cz>
* Remove old IE support
* don't need regex in normalizePath
* fix verifyPath to handle about: situations like some iframes now that there is no fallback
* improve diff
* fix logic mistake in last diff improvment
* Update url normlization test post testing upgrade
* remove un-needed document
* Improve loc coverage by removing dead paths caused by bad type checks and add some tests for other paths
* removed exception for https://github.com/microsoft/playwright/issues/5894 that was fixed in 2022 with webkit 16.0