8 Commits

Author SHA1 Message Date
Neel Raja
ac1d3f816f
Fix SSE tests and emit new "beforeMessage" event for SSE Extension (#2171)
* Emit htmx:sseBeforeMessage

* Add tests and respect cancels

* Fix syntax errors

* fix other syntax error

* finally fix these tests!
2024-01-15 14:19:00 -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
Viktor Szépe
b085d89459
Fix assorted comment typos (#1590) 2023-07-17 11:36:04 -04:00
carson
baa84e7803 get old sse syntax working 2022-02-04 19:16:13 -07:00
carson
1cb756c05e add test for SSE swapping 2020-10-19 08:20:16 -06:00
carson
8ac2baf586 switch to colon separator for sse and ws to avoid comma issues w/ URLs 2020-09-15 12:22:54 -06:00
carson
9a4ad77d5d WebSocket and SSE connection closing on element replacement 2020-05-26 06:34:41 -07:00
carson
666b4cbaa8 add tests for SSE and standardize syntax with websockets 2020-05-25 21:56:29 -07:00