Refactor Neo.manager.DomEvent.verifyDelegationPath to implement a simplified, robust "Physical Anchor" verification strategy.
Context:
Previous iterations considered complex VNode traversals to bridge the gap between physical DOM paths and logical component hierarchies (e.g., Portals, Multi-Window). However, since DomEvent.fire() now utilizes ComponentManager.getParentPath() to resolve the full logical component chain before verification, we can rely on this pre-calculated truth.
The Problem:
Delegation verification failed for detached components because the listener.vnodeId was not present in the raw physical event.path.
The Solution: Physical Anchor Verification
We implemented a 2-phase strategy that bridges the physical and logical worlds without expensive VNode scans.
Phase 1: Physical Boundary Check (Fast Path)
- Standard check: Is
listener.vnodeId in the physical path?
- If yes, the target is physically inside the listener. Valid.
Phase 2: Physical Anchor Verification (Logical Fallback)
- If Phase 1 fails, we check the
componentPath (logical chain).
- We identify the "Anchor Component": The first component ID in
componentPath (which corresponds to the first component found in the physical path by getParentPath).
- We verify that the
targetId (found by the delegate selector) is physically inside (or is) this Anchor Component.
- Logic: Target is inside Anchor (Physical) -> Anchor is inside Listener (Logical, via
componentPath). Therefore, Target is inside Listener.
Benefits:
- Performance: O(N) on path length. No recursive VNode tree traversals.
- Robustness: Correctly handles Portals (Anchor = Portal Child), Menus (Anchor = SubMenu), and Multi-Window apps (Anchor = View in Window B).
- Simplicity: Leverages the existing "Single Source of Truth" (
componentPath) rather than re-deriving relationships.
Changes:
- Updated
src/manager/DomEvent.mjs.
- Added comprehensive tests in
test/playwright/unit/manager/domEvent/Delegation.spec.mjs covering all scenarios.
Refactor
Neo.manager.DomEvent.verifyDelegationPathto implement a simplified, robust "Physical Anchor" verification strategy.Context: Previous iterations considered complex VNode traversals to bridge the gap between physical DOM paths and logical component hierarchies (e.g., Portals, Multi-Window). However, since
DomEvent.fire()now utilizesComponentManager.getParentPath()to resolve the full logical component chain before verification, we can rely on this pre-calculated truth.The Problem: Delegation verification failed for detached components because the
listener.vnodeIdwas not present in the raw physicalevent.path.The Solution: Physical Anchor Verification We implemented a 2-phase strategy that bridges the physical and logical worlds without expensive VNode scans.
Phase 1: Physical Boundary Check (Fast Path)
listener.vnodeIdin the physicalpath?Phase 2: Physical Anchor Verification (Logical Fallback)
componentPath(logical chain).componentPath(which corresponds to the first component found in the physical path bygetParentPath).targetId(found by the delegate selector) is physically inside (or is) this Anchor Component.componentPath). Therefore, Target is inside Listener.Benefits:
componentPath) rather than re-deriving relationships.Changes:
src/manager/DomEvent.mjs.test/playwright/unit/manager/domEvent/Delegation.spec.mjscovering all scenarios.