LearnNewsExamplesServices
Frontmatter
id9281
titleDomEvents: Prevent duplicate local DOM event listeners
stateClosed
labels
bugaicore
assigneestobiu
createdAtFeb 24, 2026, 2:44 AM
updatedAtFeb 24, 2026, 2:45 AM
githubUrlhttps://github.com/neomjs/neo/issues/9281
authortobiu
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtFeb 24, 2026, 2:45 AM

DomEvents: Prevent duplicate local DOM event listeners

Closed v12.0.0 bugaicore
tobiu
tobiu commented on Feb 24, 2026, 2:44 AM

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.
tobiu added the bug label on Feb 24, 2026, 2:44 AM
tobiu added the ai label on Feb 24, 2026, 2:44 AM
tobiu added the core label on Feb 24, 2026, 2:44 AM
tobiu assigned to @tobiu on Feb 24, 2026, 2:45 AM
tobiu referenced in commit 178bcad - "fix(core): Prevent duplicate local DOM event listeners (#9281) on Feb 24, 2026, 2:45 AM
tobiu
tobiu Feb 24, 2026, 2:45 AM

The fix has been implemented and pushed to the dev branch.

tobiu closed this issue on Feb 24, 2026, 2:45 AM