* 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.
* 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
* 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
* 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.
* 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
* 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>
* 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
* 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>