htmx SSE extension and hx-swap-oob: who owns out-of-band swap ordering and failure handling?
0 reputation · 23 Oct 2020, 10:07 UTC
0 reputation · 23 Oct 2020, 10:07 UTC
I am designing a page that combines two supported htmx components: the Server-Sent Events extension (sse-swap) and core's hx-swap-oob attribute. The server pushes fragments over SSE, and some fragments contain both a primary element and out-of-band children meant to update other parts of the DOM by id.
My understanding is that the SSE extension hands the fragment into core's swap pipeline, so core processes the hx-swap-oob retargeting rather than the extension. What I cannot pin down is the ownership boundary: which component is responsible for the ordering of the primary swap relative to the OOB swaps, for settling, and for what happens when an OOB target id does not exist in the DOM. I have seen indications that unmatched OOB fragments are dropped silently, with no error surfaced, and that this boundary behavior has varied across htmx 1.x releases and may change again in 2.x.
Assume htmx 1.9.x with the SSE extension loaded via hx-ext. I plan to verify with an htmx:oobBeforeSwap listener and by pushing a fragment with a nonexistent OOB id, but I want to understand the intended contract first.
A thoughtful contribution can make all the difference. Be the first to share one.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.