The SSE extension does not work with HTMX extensions that define a handleSwap method. This means that e.g. Idiomorph can't be used with SSE with the standard syntax:
<main hx-ext="morph">
<div hx-ext="sse" sse-connect="/event-stream" sse-close="close" sse-swap="message" hx-swap="morph" hx-target="#to-be-swapped">
</main>
The reason is that sse.js calls the api.swap method without providing swapOptions.contextElement. Without this defined, the downstream call to getExtensions in swapWithStyle returns an empty list and the swapping strategy is degraded to the standard htmx.config.defaultSwapStyle (innerHTML).
The fix seems to be as simple as making this change on line 283 in sse.js.
- api.swap(target, content, swapSpec)
+ api.swap(target, content, swapSpec, { contextElement: elt })
I will get a PR up asap.
The SSE extension does not work with HTMX extensions that define a
handleSwapmethod. This means that e.g. Idiomorph can't be used with SSE with the standard syntax:The reason is that
sse.jscalls theapi.swapmethod without providingswapOptions.contextElement. Without this defined, the downstream call togetExtensionsinswapWithStylereturns an empty list and the swapping strategy is degraded to the standardhtmx.config.defaultSwapStyle(innerHTML).The fix seems to be as simple as making this change on line 283 in
sse.js.I will get a PR up asap.