* 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
* allow user to override Content-Type header
* reorder the code so it won't use userSetContentType variable
* remove userSetContentType
* clarification
* remove unrelated changes
---------
Co-authored-by: gbourant <root@gbourant.com>
* 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>
* Write WS and SSE test backend in node
* Refactor pages so that the URLs work
* Add tab highlighting script
* Fix stream with multiple events
* Fix highlighting on ext links
* Refactor WS code
* Support event trigger tests
* Add some jitter to the intervals
* Delete old go backend
* Update README with new info and credits
* Update top-level README
* Move ws to dev dependencies
* Remove extraneous go server
* Fix misplace comment