LearnNewsExamplesServices
Frontmatter
id8057
title[DomEvent] Implement 3-Phase Boundary-Aware Delegation Verification
stateClosed
labels
enhancementaitestingarchitecture
assigneestobiu
createdAtDec 8, 2025, 8:32 AM
updatedAtDec 8, 2025, 8:34 AM
githubUrlhttps://github.com/neomjs/neo/issues/8057
authortobiu
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtDec 8, 2025, 8:34 AM

[DomEvent] Implement 3-Phase Boundary-Aware Delegation Verification

Closed v11.17.0 enhancementaitestingarchitecture
tobiu
tobiu commented on Dec 8, 2025, 8:32 AM

Refactor Neo.manager.DomEvent.verifyDelegationPath to support robust, boundary-aware delegation verification for complex component hierarchies.

Problem: The previous implementation only verified delegation targets against the physical DOM path. This caused failures for:

  1. Detached VDOM Components: Components physically rendered elsewhere (e.g., Portals, DragProxies) but present in the listener's VDOM.
  2. Logical Child Components: Components linked via parentComponent (e.g., Floating Menus) which are neither physically nested nor in the listener's VDOM.

Solution: Implement a 3-Phase Verification Strategy in verifyDelegationPath to balance performance and correctness:

  1. Phase 1: Physical Boundary Check (The Fast Path)

    • Iterates the raw event.path provided by the browser.
    • Checks if the delegationTarget is physically contained within the listener.vnodeId.
    • Performance: Covers ~99% of standard inline events with O(N) efficiency.
  2. Phase 2: Logical VNode Verification (The VDOM Fallback)

    • Triggered only if Phase 1 fails.
    • Uses Neo.util.VNode.getById(listenerComponent.vnode, targetId) to verify if the target exists within the listener's logical VNode tree.
    • Use Case: Portals, DragProxies, and other VDOM-connected but physically detached components.
    • Note: correctly resolves component references to "tunnel" into child component VNodes.
  3. Phase 3: Logical Component Path Verification (The Last Resort)

    • Triggered only if Phase 2 fails.
    • Checks the logical componentPath (constructed via ComponentManager from parent/parentComponent chains).
    • Verifies that the target's component ID is logically "below" or same as the listener's component ID in the hierarchy.
    • Use Case: Floating Menus and other purely logical children (linked via parentComponent) that are roots of their own VDOM trees.

Changes:

  • Modified src/manager/DomEvent.mjs to implement the 3-phase logic.
  • Added test/playwright/unit/manager/domEvent/Delegation.spec.mjs with comprehensive test cases for all scenarios:
    • Physical nesting (Standard)
    • VDOM connection (Portal/Proxy)
    • Logical connection (Menu/ParentComponent)
    • Negative case (Random element)
tobiu added the enhancement label on Dec 8, 2025, 8:32 AM
tobiu added the ai label on Dec 8, 2025, 8:32 AM
tobiu added the testing label on Dec 8, 2025, 8:32 AM
tobiu added the architecture label on Dec 8, 2025, 8:32 AM
tobiu assigned to @tobiu on Dec 8, 2025, 8:32 AM
tobiu referenced in commit 985249a - "[DomEvent] Implement 3-Phase Boundary-Aware Delegation Verification #8057" on Dec 8, 2025, 8:33 AM
tobiu closed this issue on Dec 8, 2025, 8:34 AM