bigskysoftware / bigskysoftware/htmx-extensions

SSE doesn't work with custom `handleSwap` extensions (i.e. idiomorph)

Open
#164 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
284
Forks
88
PR merge metrics
No merged PRs in 30d

Description

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:

```html



```

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`.

```diff
- api.swap(target, content, swapSpec)
+ api.swap(target, content, swapSpec, { contextElement: elt })
```

I will get a PR up asap.

Contributor guide

Open the contributing guide

Research direction

Start in sse.js around line 283, where the SSE extension calls api.swap, and compare the call with the documented custom handleSwap and Idiomorph example. Reproduce the provided HTML scenario, then verify that the swap receives the context needed to select the extension strategy and that the Idiomorph swap occurs instead of the default innerHTML swap.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.