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:
- Detached VDOM Components: Components physically rendered elsewhere (e.g., Portals, DragProxies) but present in the listener's VDOM.
- 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:
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.
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.
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)
Refactor
Neo.manager.DomEvent.verifyDelegationPathto 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:
parentComponent(e.g., Floating Menus) which are neither physically nested nor in the listener's VDOM.Solution: Implement a 3-Phase Verification Strategy in
verifyDelegationPathto balance performance and correctness:Phase 1: Physical Boundary Check (The Fast Path)
event.pathprovided by the browser.delegationTargetis physically contained within thelistener.vnodeId.Phase 2: Logical VNode Verification (The VDOM Fallback)
Neo.util.VNode.getById(listenerComponent.vnode, targetId)to verify if the target exists within the listener's logical VNode tree.Phase 3: Logical Component Path Verification (The Last Resort)
componentPath(constructed viaComponentManagerfromparent/parentComponentchains).parentComponent) that are roots of their own VDOM trees.Changes:
src/manager/DomEvent.mjsto implement the 3-phase logic.test/playwright/unit/manager/domEvent/Delegation.spec.mjswith comprehensive test cases for all scenarios: