Skip to content

Events listener cleanup - #1307

Open
thet wants to merge 7 commits into
masterfrom
events-listener-cleanup
Open

thet wants to merge 7 commits into
masterfrom
events-listener-cleanup

Conversation

@thet

@thet thet commented Nov 26, 2026

Copy link
Copy Markdown
Member

No description provided.

thet added 7 commits November 26, 2026 23:37
…r a once-event fired.

The once-event wrapper only deleted the id but left the element as a key
with an empty inner Map, keeping the element from being garbage collected.

Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
When a listener is registered with an AbortSignal, aborting it removed
the DOM listener but left the map entry, keeping the element and the
callback alive. Now the entry is removed on abort, unless it was replaced
by a later registration under the same id. With an already aborted
signal nothing is registered at all.

Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
remove_event_listener without an element iterates over all elements in
the event_listener_map. An element without removeEventListener or
without entries stopped the whole loop instead of skipping that element.

Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
…ning.

Replace the outdated comment about Safari not supporting the signal
option (supported since Safari 15). Add a test for namespaced ids.

Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
this.add_event_listener(el, event_type, name, cb, opts) registers an
event listener via events.add_event_listener under the id
"<pattern name>--<instance uuid>--<name>". destroy() removes all
listeners of the instance, but not those of other instances of the same
pattern.

Note: destroy() is not called automatically when a pattern's element is
removed from the DOM.

Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
destroy() passed a newly bound function to jQuery's off(), which never
matched the registered handler, so the handler was never removed. It also
did not call super.destroy(), so the pattern stayed registered on the
element. Now the handler is registered under an instance specific event
namespace and removed via that namespace, without touching other
instances' handlers.

Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant