-
-
Notifications
You must be signed in to change notification settings - Fork 202
DomEvents: Prevent duplicate local DOM event listeners #9281
Copy link
Copy link
Closed
Labels
aibugSomething isn't workingSomething isn't workingcoreCore framework functionalityCore framework functionality
Description
When calling addDomListeners() on a component that is already mounted, the mountDomListeners routine would re-send all existing local events (like mousemove) to the Main thread, resulting in duplicate addEventListener bindings and doubled postMessage traffic.
Root Cause:
mountDomListeners was iterating over all registered listeners for a component and adding them to the payload sent to the App Worker, without checking if they had already been mounted.
Resolution:
- Updated
mountDomListenersinsrc/manager/DomEvent.mjsto check!event.mountedfor local events, and setevent.mounted = truebefore sending. - Added
resetMountedDomListeners()toDomEventmanager to reset the flag when a component unmounts. - Added
resetMountedDomEvents()tosrc/mixin/DomEvents.mjs. - Called
me.resetMountedDomEvents?.()insrc/component/Abstract.mjswhenafterSetMountedisfalse(unmounting).
This ensures listeners are only sent once and correctly re-attached if the component remounts.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
aibugSomething isn't workingSomething isn't workingcoreCore framework functionalityCore framework functionality