* 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.
* 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>
* Prevent references to elements swapped out of the dom accumulating as detached nodes (memory leak).
* Safely delete internal data when we tear down a node
* fix: change css midBlue saturation and body tag color to a darker color
* feat: add empty alt attribute to decorative bars
* feat: add alt attributes for index link images
* fix: tweak code background alpha
* feat: add custom highlighting theme, change comment color to be legible
* fix: replace a tags with span
* fix: lighten background color of div
* feat: add doctype and meta description
* fix: remove doctype to prevent no quirks mode (why.png)