Composed event dispatch with relatedTarget across subtrees

Visualizing the DOM spec's dispatching events algorithm. The walk re-retargets relatedTarget against every parent. When it crosses upward out of a shadow tree into a wider tree, the stored shadow-adjusted target updates. The walk terminates early when parent === relatedTarget (the retargeted one). Use the scenario picker below to see this play out across shadow, light DOM, and nested shadow trees.

original target original relatedTarget currentTarget (this step)

DOM tree

Event path (built target → outward)

# invocationTarget
(= currentTarget)
shadow-adjusted target
(struct slot)
event.target
visible to listener
event.relatedTarget
visible to listener
note
Algorithm trace (verbatim from the dispatch walk)