fix/listener-accumulation #69
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/listener-accumulation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Without explicit removal, every WS reconnect soft-refresh would register additional `htmx:wsOpen`, `htmx:beforeSwap`, `htmx:afterSwap`, `htmx:oobBeforeSwap`, and `htmx:oobAfterSwap` listeners on `document.body`. After N reconnects the subscribe frame would fire N times and scroll logic would run N times per swap. Named functions replace the anonymous callbacks so they can be passed to `removeEventListener`. A `htmx:beforeCleanupElement` listener (with `{ once: true }`) on the nearest cleanup root tears everything down when HTMX replaces the enclosing fragment.