194 Commits

Author SHA1 Message Date
youssame
3e265ea263
Fix TypeError on null path variable (#2967)
* Fix the error

* add tests
2024-10-20 16:37:58 -06:00
Carson Gross
1537833ae0 Merge remote-tracking branch 'origin/dev' into dev 2024-10-02 19:58:30 -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
Joerg Sonnenberger
df92b295d6
Change hx-trigger's changed modifier to work for independent trigger specifications (#2891)
* Adjust hx-trigger's changed modifier for multiple sources

The `changed` trigger modifier can see different event targets, either due
to the `from` modifier or event bubbling. The existing behavior trigger
only for one node (`from` modifier) or inconsistently (bubbling).

Use a nested weak map to keep track of the last value per distinguished
(trigger specification, event target node) pair. The weak map ensures
that Garbage Collection can still recycle the nodes.

If a event target was not seen via `from`, it is assumed changed for the
first time the trigger is hit.

* Add test case for separate triggers with changed modifier
2024-10-02 19:17:25 -06:00
MichaelWest22
4a8172325e
enable hx-preserve handing for oob swaps (#2934)
* Add support for oob swaps with hx-preserve

* Add tests

* Documentation

* Impove fix to handle when oob swaps shouldSwap set false
2024-10-02 19:02:46 -06:00
MichaelWest22
d528c9d94d
Handle Space before comma in Trigger Spec (#2903)
* strip space after trigger spec

* Add test

* handle addiional case
2024-09-25 13:12:37 -06:00
MichaelWest22
3d1a2e5202
[bug] load trigger stops hx-disabled-elt getting re-enabled (#2925)
* allow disable-elt on load to function

* Update requestCount fallback
2024-09-25 12:13:25 -06:00
shouya
e6a2ea15a2
Documentation for dynamic hx-vals (#2898)
* add test for spread operator in hx-vals

* update documentation

Closes #2885
2024-09-13 10:19:21 +02:00
Carson Gross
97b8c68dd3 release prep 2024-08-05 13:53:08 -06:00
Kyungmin Bae
27412551a5
fix: Fire htmx:trigger event on delayed triggers (#2411)
* Add test on htmx:trigger for delayed triggers

* Fire htmx:trigger event on delayed triggers
2024-08-05 13:47:58 -06:00
Carson Gross
df3fd8fe28 Merge remote-tracking branch 'origin/dev' into dev 2024-08-05 13:46:28 -06:00
Carson Gross
42343d9194 Merge branch 'master' into dev 2024-08-05 13:41:37 -06:00
pokonski
ee9b0e0390
Do not boost forms with method="dialog" (#2752)
* Do not boost forms with method="dialog"

* Clean up
2024-08-05 13:38:51 -06:00
Carson Gross
084df38c31 only removed templates explicitly used for encapsulating oob swaps
fixes https://github.com/bigskysoftware/htmx/issues/2776
2024-08-05 13:37:31 -06:00
Igor Berlenko
49b5dae073
fixed typo in hx-trigger.js (#2728)
Update hx-trigger.js
2024-07-26 00:27:22 -04:00
Denis Palashevskii
dc93911566
Add tests for getSelectors method for extension registration (#2508)
add tests for getSelectors method for extension registration
2024-04-25 13:45:33 -06:00
Carson Gross
01cb5e0d8d support hx-on in shadowroot 2024-04-17 05:25:28 -06:00
Joe Taber
520502121e
Add config option to ignore nested oob-swaps instead of processing them (#1235)
* Add config option to ignore nested oob swaps

* Fix oobElement root check

* Save config between tests; repeat some tests with different configs

* Add tests for oob-swaps in html, body tags

* Don't unnecessarily change const to var
2024-03-11 12:32:30 -04:00
p.b
d1fc7895f6
Add textContent swap style (#2356)
* feat: add textContent swap style

* add documentation

---------

Co-authored-by: pbt <pb.to@icloud.com>
2024-02-29 11:11:46 -05:00
Alexander Petros
0e67ac8081 Format tests 2024-01-18 10:20:34 -05:00
Carson Gross
5cdd50ebbe fix test 2024-01-05 11:00:08 -07:00
Carson Gross
8c61e71940 support revealed paired w/ other events 2023-12-26 16:42:16 -07:00
Carson Gross
9fbbd17672 reformat 2023-12-24 16:37:51 -07:00
Carson Gross
adbdc71c81 add another test for inheritance disabling 2023-12-24 15:06:11 -07:00
Carson Gross
42668c6df7 Merge branch 'v2.0v2.0' into disable-inheritance
# Conflicts:
#	src/htmx.js
#	www/content/docs.md
2023-12-24 14:55:11 -07:00
Vincent
b9da68d970
Support encapsulating oob swap elements in templates in response (#2120) 2023-12-21 12:39:23 -07:00
Alexander Petros
4b890ce72d Run linter on the tests too 2023-12-21 13:22:10 -05:00
Carson Gross
41e9ce3593 Merge branch 'dev' into v2.0v2.0 2023-12-20 15:48:47 -07:00
Carson Gross
b4080e71da remove psychotic test 2023-12-20 15:48:31 -07:00
Thomas Cowart
078d5da5b4
Update parseInterval to handle "0" correctly (#1835)
* Update parseInterval to handle "0" correctly

When a parameter like "0ms" is passed in to parseInterval it gets parsed to 0.
Previously this would result in a return value of "undefined" because 0 is falsy
and thus the `return 0 || undefined` statements return undefined.

The purpose of the form `parseFloat(str) || undefined` was to return "undefined" if
parseFloat failed (parseFloat returns NaN, a falsy value, if it can't parse its
argument). Unfortunately, as mentioned, parseFloat can also succeed and return a
falsy value -- when the argument is "0" (or "0.0", etc.). So the new code, rather
than depending on the falsiness of the result of parseFloat, explicitly checks for
a NaN.

* Adds some semicolons

Adds some semicolons to parseInterval (and tests) for consistency.

* Add one more parseInterval test for "0"

Adds test test to make sure parseInterval works on "0".

* Adds functional tests for every, swap, settle, throttle, and delay

* Explcitly check that setTimeout values are > 0

These values come from user settings that are read from parseInterval,
so they could be a number or undefined.

If the value being checked is > 0 setTimeout will be called with some
associated function. If the value is 0 or 'undefined' the associated function
will be called immediately ('undefined' is not greater than 0).

* Change '!== undefined' to '> 0'

`pollInterval !== undefined` is a subtly different conditional than just `pollInterval` or `pollInterval > 0` (which are equivalent). Changes the conditional to `pollInterval > 0` so as to not change the behavior but also be more explicit in the test.
2023-12-20 15:46:04 -07:00
Denis Palashevskii
23256373fc
Remove legacy WS/SSE code (#2095)
* apply updated patch with legacy WS/SSE removal

* remove legace WS/SSE from the test server also

* remove sse mention from getTriggerSpec()

* clean up sse.js implementation after removal of hx-sse
2023-12-14 15:54:16 -07:00
fhp-mec
11cef8ee83
Fix: Make the SSE extension work properly and adhere to tests (#2025)
* Process sse-swap properly when swapped in

Previously `sse-swap` were only processed when `sse-connect` was on the
root of what was being swapped in.
This is now fixed so that the closest sseEventSource is found and used as the
event source

* Pass for code readabiltiy

remove the nested if statements as there is no difference in handling
between sseURL and LegacySSEUrl.

* Fix indenting

* Initial attempt at sse extension tests

* Make existing tests pass

* Add test case for #916

* backport test for #916 to hx-sse for completeness

* add a distinct test for sse-swap

* more tests, fix tests

+ more tests differentiating the implementation of sse-swap and
hx-trigger
* fix for "is closed after removal with no close and activity"

* Cleanup listener if element is gone

* Revert "Cleanup listener if element is gone"

This reverts commit bbe3715276302656d1a422fbc4778842776e35f6.

* Clean up listeners if element gone, fix indenting

* Incorportate feedback from first review

+ seperate eventSource creation logic and event registering logic
+ manually create event handling, still confused by how hx-trigger works
* `createEventSourceOnElement` now looks for event sources in children
* explicitly handle legacy sse handling instead of having extra
  selectors in `querySelectorOnThisOrChildren`
+ a few readability changes
+ add regression check to make sure that sseEventSource is only created
  on elements with sse-connect or equivalent
+ add test to make sure that sse-connect in the child of a swapped
  element is handled

* Allow multiple listeners in eventsource mock

* Backport eventsource mocks to legacy tests

---------

Co-authored-by: 1cg <469183+1cg@users.noreply.github.com>
2023-12-14 14:33:38 -07:00
Vincent
4057f9c465
Trigger specs cache indentation fix + documentation & tests (#2094)
* Fix parseAndCacheTrigger indentation as discussed in #1540

https://github.com/bigskysoftware/htmx/pull/1540#issuecomment-1834651800

* Trigger specs cache documentation + tests
2023-12-14 11:44:11 -07:00
Carson Gross
ad871a9576 Merge branch 'v2.0v2.0' into disable-inheritance
# Conflicts:
#	src/htmx.js
2023-12-13 17:08:52 -07:00
Carson Gross
3be4202e5e add support for dashes in hx-on* attributes 2023-12-07 15:15:10 -07:00
Dan Palmer
0b37d0507d
Fix relative resource URLs for boosted links (#1960)
Fix relative URLs
2023-11-19 07:56:06 -07:00
Jonathan Rietveld
7ef95e8963
Allow CSS selectors with whitespace in hx-trigger (#1913)
* Allow CSS selectors with whitespace in `hx-trigger`

Parsing of `hx-trigger` scans for whitespace, so if a CSS selector is used that contains whitespace, e.g. `form input`, a syntax error is raised.
A workaround is implemented by allowing such a CSS selector to be wrapped in either curly braces or parentheses.

* Add explanation whitespace in CSS selector to docs

* Tests for CSS selectors containing whitespace

* Use faster RegEx test, remove redundant variable declarations

* Added Descendant Combinator support to `root` and `target` modifiers

* Add missing semicolon

* Tests for descendant combinators in `root` and `target` modifiers

* Improve descendant combinator test coverage
2023-11-16 13:45:46 -07:00
Carson Gross
69c053c136 initial inheritance disabling work 2023-11-14 16:27:49 -07:00
Vincent
8ddd079b90
IE11 compatibility fixes (#1948) 2023-11-02 16:40:33 -06:00
Raphaël Piccolin
fdd2570ac8
fix: prevent nodeData.onHandlers overwrite (#1894)
* fix: prevent nodeData.onHandlers() overwrite

* fix: improved type safety

* test: hx-on handler cleanup

* style: wording

* chore: extra line
2023-10-26 14:45:46 -06:00
matiboy
712ee759f1
Fix confirmed being ignored in htmx:confirm event (#1610)
* Current behavior testing

Testing current library behavior

* Test should remove correct handler

* Add question in htmx:confirm event detail

* Allow skipping window.confirm

* Additional test without hx-confirm value

* Wrap htmx.off in finally

* More correct assertion in case of no calls to confirm

* Remove erroneously added formatting

* Remove erroneously added formatting

* Documentation, fix loop

---------

Co-authored-by: mat <matt@techspace.asia>
2023-10-26 14:43:41 -06:00
Vincent
7274454360
[New feature] selector-less next and previous targets (#1478)
* nextElementSibling and previousElementSibling target selectors

* Renamed nextElementSibling => next, previousElementSibling => previous
2023-10-06 22:25:03 -06:00
Carson Gross
a5fd1b7081 make singular to make more consistent w/ other attributes 2023-09-21 16:57:28 -06:00
Sam Dudley
8da65b94e5
Fix swapError with hx-on and innerHTML swap (#1371)
Add tests for hx-on can handle being swapped using innerHTML
2023-09-21 12:11:02 -06:00
Carson Gross
af0dc9c352 add hx-disabled-elts functionality 2023-09-14 13:20:46 -06:00
Sascha Woo
81ac34994a
Support event names with "." character (#1453)
hx-on throws an error when used with event names that contain dots
2023-09-14 10:58:42 -06:00
Sascha Woo
f15795e79c
Allow hx-swap options to be used without specifying modifier (innerHTML remains the default) (#1455)
* hx-swap: make swap style optional

* hx-swap: log an error when an unknown option or modifier is used
2023-09-14 10:57:30 -06:00