Skip to content

HTMX "steals" classes added during settle #412

@lngr

Description

@lngr

The transition behaviour described here has an unintended side effect, which breaks our application. The same use case worked with Intercooler.js, but for other reasons we must migrate to HTMX. In particular HTMX removes classes on replaced DOM elements that have been added to the swapped DOM element during the settle period.

Assume you have a target as follows:

<div id="target">
    <div id="replaced" class="irrelevant"></div>
</div>

We are going to replace #target's innerHTML via hx-post/hx-swap with the following HTML returned by the server:

<div id="replaced" class="first"></div>

Now assume after the #replaced element has been swapped into the DOM but before the DOM is settled (before htmx-settling is removed), #replaced has gained another class second. Then, after the settle delay, HTMX sets the class attribute to the value originally obtained from the server (here: "first") and therefore effectively removes the second class from #replaced.

If would therefore be great if there was a way to disable the settling mechanism during specific swaps.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions