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
mountDomListeners in src/manager/DomEvent.mjs to check !event.mounted for local events, and set event.mounted = true before sending.
- Added
resetMountedDomListeners() to DomEvent manager to reset the flag when a component unmounts.
- Added
resetMountedDomEvents() to src/mixin/DomEvents.mjs.
- Called
me.resetMountedDomEvents?.() in src/component/Abstract.mjs when afterSetMounted is false (unmounting).
This ensures listeners are only sent once and correctly re-attached if the component remounts.
When calling
addDomListeners()on a component that is already mounted, themountDomListenersroutine would re-send all existing local events (likemousemove) to the Main thread, resulting in duplicateaddEventListenerbindings and doubledpostMessagetraffic.Root Cause:
mountDomListenerswas 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:
mountDomListenersinsrc/manager/DomEvent.mjsto check!event.mountedfor local events, and setevent.mounted = truebefore sending.resetMountedDomListeners()toDomEventmanager to reset the flag when a component unmounts.resetMountedDomEvents()tosrc/mixin/DomEvents.mjs.me.resetMountedDomEvents?.()insrc/component/Abstract.mjswhenafterSetMountedisfalse(unmounting). This ensures listeners are only sent once and correctly re-attached if the component remounts.