Skip to content

DomEvents: Prevent duplicate local DOM event listeners #9281

@tobiu

Description

@tobiu

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.

Metadata

Metadata

Assignees

Labels

aibugSomething isn't workingcoreCore framework functionality

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions