4 Commits

Author SHA1 Message Date
Vladyslav Tkachenko
21cdfcf17c
SSE Ext #2225: reinstantiate EventSource listeners upon reconnection logic (#2272)
* fix(sse): reinstantiate EventSource listeners
upon reconnection logic

refs #2225

* improve initialization logic of SSE on nested elements

---------

Co-authored-by: Denis Palashevskii <palash.denis@outlook.com>
2024-02-25 23:25:03 +01:00
Denis Palashevskii
1a8afc3502
fix sse-swap removal handling in ext/sse.js (#2247) 2024-02-25 20:58:39 +01:00
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