LearnNewsExamplesServices
Frontmatter
id7043
titleRefactor: Extract DOM Event Handling to `DomEvents` Mixin
stateClosed
labels
enhancement
assigneestobiu
createdAtJul 13, 2025, 7:13 PM
updatedAtJul 13, 2025, 7:14 PM
githubUrlhttps://github.com/neomjs/neo/issues/7043
authortobiu
commentsCount0
parentIssue6992
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJul 13, 2025, 7:14 PM

Refactor: Extract DOM Event Handling to DomEvents Mixin

Closed v10.0.0-beta.6 enhancement
tobiu
tobiu commented on Jul 13, 2025, 7:13 PM

Description: Currently, DOM event handling logic, including the domListeners_ config and related methods (afterSetDomListeners, addDomListeners, removeDomListeners), resides within src/component/Base.mjs.

To enable consistent DOM event support for both class-based components (src/component/Base.mjs) and functional components (src/functional/component/Base.mjs), and to improve code organization and reusability, this ticket proposes extracting this logic into a new mixin: src/mixin/DomEvents.mjs.

Proposed Changes:

  1. Create src/mixin/DomEvents.mjs:

    • Define the domListeners_ config.
    • Move afterSetDomListeners, addDomListeners, and removeDomListeners methods to this mixin.
    • Add initDomEvents() and removeDomEvents() methods to encapsulate the mounting and unmounting of DOM listeners, respectively. These methods will be called from the component's lifecycle hooks.
  2. Refactor src/component/Base.mjs:

    • Remove the domListeners_ config and the methods moved to DomEvents.mjs.
    • Add Neo.mixin.DomEvents to its mixins array.
    • Call this.initDomEvents() within its afterSetMounted() method.
    • Call this.removeDomEvents() within its destroy() method.
  3. Update src/functional/component/Base.mjs:

    • Add Neo.mixin.DomEvents to its mixins array.
    • Implement (or modify existing) afterSetMounted() and destroy() methods to call this.initDomEvents() and this.removeDomEvents(), respectively.

This refactoring will ensure that both component types benefit from a centralized and reusable DOM event management system, aligning with the framework's pattern of using mixins for shared functionality.

tobiu assigned to @tobiu on Jul 13, 2025, 7:13 PM
tobiu added the enhancement label on Jul 13, 2025, 7:13 PM
tobiu added parent issue #6992 on Jul 13, 2025, 7:13 PM
tobiu referenced in commit 58743c8 - "Refactor: Extract DOM Event Handling to DomEvents Mixin #7043" on Jul 13, 2025, 7:14 PM
tobiu closed this issue on Jul 13, 2025, 7:14 PM