668 Commits

Author SHA1 Message Date
MichaelWest22
cee310e4d5
Handle not preventing link when inside htmx enabled element (#3396)
* 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
2025-09-07 12:09:05 -06:00
MichaelWest22
448db781ef
add back null check for no form in getRelatedFormData (#3394) 2025-07-27 09:34:50 -06:00
MichaelWest22
081adf8eeb
Fix ajax api body test (#3073)
fix api body test to not replace body and just check target
2025-07-21 21:42:30 -04:00
MichaelWest22
9d598f8d6e
implement reportValidity for reporting proper form validation errors behind config flag (#3372)
* implement reportvalidity behind feature flag

* add tests
2025-07-14 19:04:17 -06:00
Carson Gross
dc804932a7 fix formatting 2025-07-14 18:21:16 -06:00
MichaelWest22
28fae544c2
Cancel button with inner content form submit properly (#3368)
Co-authored-by: 1cg <469183+1cg@users.noreply.github.com>
2025-07-14 17:41:26 -06:00
Matteo Smaila
b0c87bf363
Bugfix: swap="outerHTML" on <div> with style attribute leaves htmx-swapping class behind (#3341)
* 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>
2025-07-14 17:37:40 -06:00
MichaelWest22
8e489ef6ee
fix click events on elements wrapped by link don't cancel link navigation (#3357)
fix click events on elements wrapped by link doesn't cancel link navigation
2025-06-27 07:33:28 -06:00
Simon Hartley
e2353e26bc
Allow use of "this" when evaluating hx-vals (#3332)
Evaluate hx-vals with "this" referring to the element it is defined on

Co-authored-by: scrhartley <scrhartley@github.com>
2025-06-20 14:52:17 -06:00
MichaelWest22
dc71b317d0
throw targetError correctly when target invalid during retarget (#3335)
* throw targetError correctly when target invalid during retarget

* fix missing jsdoc return
2025-06-20 14:51:12 -06:00
MichaelWest22
84306ccf3d
Fix non chrome view transtions tests (#3338)
fix non chrome view transitions tests
2025-06-19 15:02:11 -06:00
MichaelWest22
c091b95fa3
Move currentPathForHistory to session storage (#3330)
* Move currentPathForHistory to session storage

* update test

* fix more sessionStorage from localStorage
2025-06-16 18:24:39 -05:00
MichaelWest22
c9e2bea954
Fix Modified click trigger on form elements prevent default behaviour (#3336)
Fix Modified click trigger on form elements prevent default behaviour of clicked element
2025-06-16 18:09:32 -05:00
MichaelWest22
7388d0c057
Move History storage to sessionStorage (#3305)
* Move History storage to sessionStorage and history path to window

* Fix type warnings

* Revert currentPathForHistory to move it to its own PR

* fix test
2025-06-16 18:08:34 -05:00
MichaelWest22
508e332544
Standardize history restore functions to use proper htmx swap functions (#3306)
* 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
2025-06-16 16:53:57 -06:00
MichaelWest22
859708c379
move delay and view transitions to inside swap function for api and history use (#3328)
* 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
2025-06-16 17:31:07 -05:00
Ryan Kilpadi
5b4d77da6b
Attach hx-on handlers before processing nodes (#3131) 2025-06-02 15:50:19 -05:00
Vincent
82546dbd47
Inherit list-keyword in hx-include / hx-indicator (#1766)
Inherit keyword in hx-include / hx-indicator
2025-06-02 11:20:24 -06:00
Jeremiah Johnson
4184d1fd0c
fix(swap): apply swap delay in swap function instead of handleAjaxResponse (#2845)
* fix(swap): apply swap delay in swap function instead of handleAjaxResponse

* add swap delay test
2025-06-02 11:19:11 -06:00
Oliver Haas
6d238f3d61
Feat/hx reselect support unset (#3153)
feat: handle 'unset'for HX-Reselect in swap function (+ test)
2025-06-02 11:01:20 -06:00
Simon Hartley
075ed73799
Fix target value in htmx:targetError when inheritance has been used (#3178)
Co-authored-by: scrhartley <scrhartley@github.com>
2025-06-02 10:58:31 -06:00
David Martiník
730bd8224d
Fixes issue 1537 - OOB does not escape query selector - updated version (#3304)
* 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>
2025-06-02 10:52:29 -06:00
MichaelWest22
5520566fc3
Add historyRestoreAsHxRequest config to optionally disable hx-request header from history restore requests (#3278)
* Added Config to optionally disable the breaking HX-Request change made recently

* fix broken resolved conflict
2025-04-24 14:21:23 -06:00
Simon Hartley
db8e5e03cb
Fix event not being available in hx-vals/hx-vars when hx-trigger has delay (#3196)
Fix event not being available in hx-vals/hx-vars when hx-trigger uses delay

Co-authored-by: scrhartley <scrhartley@github.com>
2025-04-24 13:58:31 -06:00
Simon Hartley
6a585f9f3c
Get rid of latest usages of substr (#3074)
* Replace latest usages of substr

* Replace usage of substr in tests

---------

Co-authored-by: scrhartley <scrhartley@github.com>
2025-04-24 13:56:55 -06:00
MichaelWest22
05d37e6ea6
Remove old IE support (#3277)
* 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
2025-04-24 13:56:05 -06:00
MichaelWest22
d3bcd787ba
proxy window.location for testing and extension overrides (#3283)
* proxy window.location for testing and extension overrides

* when not whe in test name
2025-04-24 13:55:27 -06:00
MichaelWest22
408850a08e
Additional Code Coverage (#3282)
* 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
2025-04-24 13:54:43 -06:00
MichaelWest22
21dc121fce
handle removing request lock on errors (#3284)
* handle removing request lock on errors

* Fixed non function verifyUrl tests and added tests for the double requests this PR fixes
2025-04-24 13:53:14 -06:00
MichaelWest22
24a0106f76
Update testing framework to web-test-runner and improve code coverage (#3273)
* Fix old npm dependencies

* implement web-test-runner tests for headless alongside Mocha browser tests

* Increase test and code coverage

* update to 100% coverage and impove eslint

* Update testing Doco

* revert all htmx changes and updates/disable tests needed

* fix browser mocha test

* Default testing to use playwrite only instead of puppeter

* playwright install fix

* Imporve test summary reporting

* flatten false looks closer to original
2025-04-17 17:55:43 -06:00
Geoffrey B. Eisenbarth
9fcb5c5c32
Enforce no-op on submit buttons with formmethod=dialog. (#3075)
* Enforce no-op on submit buttons with formmethod=dialog.

* Properly resolve referenced forms. (#3094)

* Properly resolve referenced forms.

* Clarify variable.

* Cast elt to avoid TS exceptions.

* Refactor for JSDoc.

* Clarify shouldCancel.

* Remove complicated JSDoc in favor of ts-ignore.

* More coverage for button scenarios.

* Use properties instead of matching.

* Mention reset button change.

* Mention formmethod=dialog change.
2025-01-09 15:22:36 -07:00
Geoffrey B. Eisenbarth
f46989b24a
Properly resolve referenced forms. (#3094)
* Properly resolve referenced forms.

* Clarify variable.

* Cast elt to avoid TS exceptions.

* Refactor for JSDoc.

* Clarify shouldCancel.

* Remove complicated JSDoc in favor of ts-ignore.

* More coverage for button scenarios.

* Use properties instead of matching.

* Mention reset button change.
2025-01-09 11:23:32 -07:00
Geoffrey B. Eisenbarth
cc2466b1f8
Cancel vanilla submits from <button[form]/>. (#3072) 2024-12-12 13:09:26 -07:00
Vincent
a331244923
Support multiple extended selectors for hx-include, hx-trigger from, and hx-disabled-elt (#2902)
* Initial suggestion (squashed)

Support multiple extended selectors for hx-include

Additional test for nested standard selector

Add @MichaelWest22 hx-disabled-elt multiple selector test

Add hx-trigger `from` test with multiple extended selectors

Simplify

Include #2915 fix

Update htmx.js

Split for readability

Don't apply global to previous selectors

Rewrite loop, restore global recursive call, minimize diff

Use break for better readability

Co-Authored-By: MichaelWest22 <12867972+MichaelWest22@users.noreply.github.com>

* Keep global as a first-position-only keyword

* Wrapped selector syntax

* Replace substring check by individual chars check

* Fix format

---------

Co-authored-by: MichaelWest22 <12867972+MichaelWest22@users.noreply.github.com>
2024-12-12 11:12:01 -07:00
Carson Gross
232667d2c6 fix https://github.com/bigskysoftware/htmx/issues/1788
boosted forms that issue a `GET` (and only a `GET`) and have no `action` attribute or an empty `action` attribute should clear the existing parameters of the current path when submitting lmao
2024-12-11 16:42:20 -07:00
Carson Gross
815c117088 comment out test that is breaking suite in browser 2024-12-11 15:06:03 -07:00
basvk
34dda10f9e
Do not execute hx-trigger="load" on re-initialization of an existing node (#2976)
* Do not execute hx-trigger="load" on re-initialization of an existing node

* simplify initNode firstInit logic
2024-12-11 14:27:34 -07:00
Alexander Petros
bd35f64cf7
Add missing htmx:trigger event on load triggers (#3033) 2024-12-11 14:20:12 -07:00
Simon Hartley
62969122f1
Fix illegal invocation for FormData proxy (#2997)
Fix illegal invocation for a FormData proxy returning a function looked-up via a symbol

Co-authored-by: shartley <scrhartley@github.com>
2024-11-07 10:15:07 -07:00
MichaelWest22
816fe6d161
ajax helper with no source or target defaults to body (#2948) 2024-10-20 16:38:41 -06:00
youssame
3e265ea263
Fix TypeError on null path variable (#2967)
* Fix the error

* add tests
2024-10-20 16:37:58 -06:00
Kian Yang Lee
f0964d2d08
docs: migrate realtime server implementation (#2955)
Removes the realtime server for testing WebSockets and Server Sent
Events (SSE) in htmx to the extension repository, as mentioned in issue #2944.
2024-10-13 10:09:32 +02:00
Carson Gross
1c4d378d03 fix formatting 2024-10-02 20:11:29 -06:00
Carson Gross
c7278c448e fix test (firefox, safari) 2024-10-02 20:09:11 -06:00
Carson Gross
1537833ae0 Merge remote-tracking branch 'origin/dev' into dev 2024-10-02 19:58:30 -06:00
MichaelWest22
958fef20d9
Add shadowRoot host selector (#2866) 2024-10-02 19:46:11 -06:00
Jonathan
99285cd5c3
fix for hx-swab-oob within web components (#2846)
* Failing test for oob-swap within web components

* hx-swap-oob respects shadow roots

* Lint and type fixes

* fix jsdoc types for rootNode parameter

* Fix for linter issue I was confused about before

* oob swaps handle global correctly

* swap uses contextElement if available, document if not

Previous a commit made swapOptions.contextElement a required field. This
could have harmful ramifications for extensions and users, so instead,
the old behavior of assuming document as a root will be used if the
contextElement is not provided.

* rootNode parameter is optional in oobSwap

If not provided, it will fall back to using document as rootNode. jsdocs
have been updated for oobSwap and findAndSwapElements accordingly.
2024-10-02 19:44:41 -06:00
Nathan
8c6582679b
Better graceful degradation of boosted form element (#2802)
* better graceful degradation of form elt

* smaller

* move fix and add tests
2024-10-02 19:44:13 -06:00
MichaelWest22
0e1eeec8b4
remove extra hx-swap-oob attribute that is not used in the page (#2823)
remove extra hx-swap-oob tag that is not used in the page
2024-10-02 19:40:54 -06:00
Eric Kwoka
b23b2f034e
🐛 Prevents erroring on null vals (#2799)
* 🐛 Prevents erroring on null vals

* 🚧 Applies same fix in FormProxy

* 🧪 Adds Test for null in FormDataProxy
2024-10-02 19:21:02 -06:00