bigskysoftware / bigskysoftware/htmx-extensions

Fix global swap configuration conflict with local text content swap

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

Description

## Why

Hello. :wave: I've run into a situation where setting default behavior for htmx causes a weird edge case when using the SSE extension in regards to swapping of content.

## How

To recreate, add a global htmx configuration as follows:

``` html

```

Then you can render a template with the following setup:

``` html

<%= image_tag "loader.svg", alt: "Loader", width: 800, height: 480 %>

<%= render :welcome %>

```

The critical piece is the use of `hx-swap="textContent"` in the text area. Use of `textContent` for swapping purposes completely fails when the global htmx configuration uses `outerHTML` as the default swap behavior. If you remove the global configuration, everything works properly. For some reason, the SSS extension appears to not honor the `textContent` swap style when the global configuration is in play.

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue using the htmx-config with defaultSwapStyle set to outerHTML, the SSE extension example, and hx-swap="textContent" on the textarea. Inspect the SSE extension's swap handling and verify that local textContent behavior is preserved despite the global configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.