bigskysoftware / bigskysoftware/htmx

Behaviour when disconnected/unmounted from body

Open
#2,526 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
49.4k
Forks
1.7k
Avg merge
3d 22h
Merged PRs (30d)
30

Description

htmx seems to cancel a some of its behaviours if events fire while nodes are not a part of the body:
https://github.com/bigskysoftware/htmx/blob/57595bc0390b6ed98ada45a5d27156322e308757/src/htmx.js#L1514-L1517
https://github.com/bigskysoftware/htmx/blob/57595bc0390b6ed98ada45a5d27156322e308757/src/htmx.js#L1778-L1781
https://github.com/bigskysoftware/htmx/blob/57595bc0390b6ed98ada45a5d27156322e308757/src/htmx.js#L1812-L1817

This makes it difficult to integrate with other frameworks (eg React), where the DOM node may be unmounted and then later remounted. Users have to ensure that unmounting and remounting occurs synchronously, which can be difficult.

Calling htmx.process might not [re-init if attributes are unchanged](https://github.com/bigskysoftware/htmx/blob/57595bc0390b6ed98ada45a5d27156322e308757/src/htmx.js#L2128-L2129), and deInitNode is not exported by htmx. However, ideally we'd not re-process at all.

Ideally when these events trigger on unmounted nodes, the listeners don't get removed, and instead the effect not performed. This seems to be a pattern used elsewhere in htmx. Explicit deInits could be invoked if the users want to ensure the effects of htmx-powered DOM are disabled

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.