Re: [w3c/webcomponents] "The event relatedTarget retargeting process must occur prior to dispatch of an event." (#485)

Okay, so how about this:
```
Event has an associated **path** (an ordered set of tuples).

Dispatch(event, target, targetOverride):

  -> Set event's dispatch flag.

  -> Append (target, target) to event's path.

  -> Let parent be the result of invoking target's "get the parent" with event.

  -> While parent is non-null:

    -> If target's root is a shadow-including inclusive ancestor of parent, 
       then append (parent, null) to event's path.

    -> Otherwise:

      -> Set target to parent.

      -> Append (parent, target) to event's path.

    -> Set parent to the result of parent's "get the parent" with event.

  -> For each _tuple_ in event's path, in reverse order:

    -> If _tuple_'s target is non-null:

      -> Set event's phase to TARGET.

    -> Otherwise:

      -> Set event's phase to CAPTURE.

      -> Set event's target to the target of the last tuple in event's path 
         before _tuple_ whose target is non-null.

      -> If targetOverride is given, set event's target to targetOverride.

         Note: targetOverride is only ever used to change the target from Window to Document.

    -> If event's stop propagation flag is unset, then invoke _tuple_'s 
       item with event.

  -> If event's bubbles attribute is value is true: 

    -> Set event's phase to BUBBLE.

    -> For each _tuple_ in event's path, in order, if _tuple_'s target is null 
       and event's stop propagation flag is unset, then invoke _tuple_'s item 
       with event.

  -> Set event's phase to NONE.

  -> Set event's currentTarget to null.

  -> Return false if event's canceled flag is set, and true otherwise.
```
This does mingle the CAPTURE and TARGET phase, which I now realize Shadow DOM does differently (it seems to want to mingle TARGET and BUBBLE). Any reason Shadow DOM does what it does? Seems more natural to handle TARGET on the way down.

I also realized that the stop propagation flag should probably move to invoke since checking it each time we run invoke is rather redundant.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/485#issuecomment-212938463

Received on Thursday, 21 April 2016 14:17:37 UTC