From ccf91dd0f4e0f859777ef1569205ea0b0b61870b Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Thu, 6 Sep 2018 14:15:41 +0200 Subject: [PATCH 1/2] Editorial: event's patch consists of structs As pointed out in #685 this was a bit confusing. --- dom.bs | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/dom.bs b/dom.bs index cd4abffe..e1db26a7 100644 --- a/dom.bs +++ b/dom.bs @@ -1306,14 +1306,14 @@ for discussion).
  • Set slot-in-closed-tree to false. -

  • Let clearTargetsTuple be the last tuple in event's +

  • Let clearTargetsStruct be the last struct in event's path whose target is non-null. -

  • Let clearTargets be true if clearTargetsTuple's - target, clearTargetsTuple's relatedTarget, - or an {{EventTarget}} object in clearTargetsTuple's - touch target list is a node and its root is a - shadow root, and false otherwise. +

  • Let clearTargets be true if clearTargetsStruct's + target, clearTargetsStruct's + relatedTarget, or an {{EventTarget}} object in + clearTargetsStruct's touch target list is a node + and its root is a shadow root, and false otherwise.

  • Set event's {{Event/eventPhase}} attribute to {{Event/CAPTURING_PHASE}}. @@ -1322,18 +1322,18 @@ for discussion). legacy-pre-activation behavior.

  • -

    For each tuple in event's path, in reverse order: +

    For each struct in event's path, in reverse order:

      -
    1. If tuple's target is null, then invoke with - tuple, event, and legacyOutputDidListenersThrowFlag if given. +

    2. If struct's target is null, then invoke with + struct, event, and legacyOutputDidListenersThrowFlag if given.

  • -

    For each tuple in event's path, in order: +

    For each struct in event's path, in order:

      -
    1. If tuple's target is non-null, then set +

    2. If struct's target is non-null, then set event's {{Event/eventPhase}} attribute to {{Event/AT_TARGET}}.

    3. Otherwise, set event's {{Event/eventPhase}} attribute to @@ -1342,7 +1342,7 @@ for discussion).

    4. If either event's {{Event/eventPhase}} attribute is {{Event/BUBBLING_PHASE}} and event's {{Event/bubbles}} attribute is true or event's {{Event/eventPhase}} attribute is {{Event/AT_TARGET}}, then invoke with - tuple, event, and legacyOutputDidListenersThrowFlag if given. + struct, event, and legacyOutputDidListenersThrowFlag if given.

    @@ -1405,23 +1405,23 @@ for discussion). slot-in-closed-tree is slot-in-closed-tree. -

    To invoke, given a tuple, +

    To invoke, given a struct, event, and an optional legacyOutputDidListenersThrowFlag, run these steps:

    1. Set event's target to the target of the - last tuple in event's path, that is either tuple or - preceding tuple, whose target is non-null. + last struct in event's path, that is either struct or + preceding struct, whose target is non-null. -

    2. Set event's relatedTarget to tuple's +

    3. Set event's relatedTarget to struct's relatedTarget. -

    4. Set event's touch target list to tuple's +

    5. Set event's touch target list to struct's touch target list.

    6. If event's stop propagation flag is set, then return. -

    7. Initialize event's {{Event/currentTarget}} attribute to tuple's +

    8. Initialize event's {{Event/currentTarget}} attribute to struct's item.

    9. @@ -1505,7 +1505,7 @@ for discussion).
      1. Set currentEvent to global's current event. -

      2. If tuple's item-in-shadow-tree is false, then set +

      3. If struct's item-in-shadow-tree is false, then set global's current event to event.

      @@ -5685,8 +5685,9 @@ or "closed").

      A shadow root's get the parent algorithm, given an event, returns null if event's composed flag is unset and shadow root is the -root of event's path's first tuple's item, and -shadow root's host otherwise. +root of event's path's first struct's +item, and shadow root's host +otherwise.

      The mode attribute's getter must return the context object's mode.

      From 7aaff50d3e165f2d5b4db3aaab260cf5027b9c00 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Thu, 6 Sep 2018 14:42:27 +0200 Subject: [PATCH 2/2] Fix event path iteration Instead of shoehorning all target handling into the bubbling iteration, this separates "capturing" iteration from "bubbling" iteration and the Event object's phase is set to target as appropriate in both. This also invokes the event listeners in a more natural order. Tests: https://github.com/web-platform-tests/wpt/pull/13030 & https://github.com/web-platform-tests/wpt/pull/13031. Fixes #685. --- dom.bs | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/dom.bs b/dom.bs index e1db26a7..eff8a33f 100644 --- a/dom.bs +++ b/dom.bs @@ -1315,22 +1315,28 @@ for discussion). clearTargetsStruct's touch target list is a node and its root is a shadow root, and false otherwise. -
    10. Set event's {{Event/eventPhase}} attribute to {{Event/CAPTURING_PHASE}}. -

    11. If activationTarget is non-null and activationTarget has legacy-pre-activation behavior, then run activationTarget's legacy-pre-activation behavior.

    12. -

      For each struct in event's path, in reverse order: +

      For each struct in event's path, in + reverse order:

        -
      1. If struct's target is null, then invoke with - struct, event, and legacyOutputDidListenersThrowFlag if given. +

      2. If struct's target is non-null, then set + event's {{Event/eventPhase}} attribute to {{Event/AT_TARGET}}. + +

      3. Otherwise, set event's {{Event/eventPhase}} attribute to + {{Event/CAPTURING_PHASE}}. + +

      4. Invoke with struct, event, "capturing", and + legacyOutputDidListenersThrowFlag if given.

    13. -

      For each struct in event's path, in order: +

      If event's {{Event/bubbles}} attribute is true, then for each + struct in event's path:

      1. If struct's target is non-null, then set @@ -1339,10 +1345,8 @@ for discussion).

      2. Otherwise, set event's {{Event/eventPhase}} attribute to {{Event/BUBBLING_PHASE}}. -

      3. If either event's {{Event/eventPhase}} attribute is {{Event/BUBBLING_PHASE}} - and event's {{Event/bubbles}} attribute is true or event's - {{Event/eventPhase}} attribute is {{Event/AT_TARGET}}, then invoke with - struct, event, and legacyOutputDidListenersThrowFlag if given. +

      4. Invoke with struct, event, "bubbling", and + legacyOutputDidListenersThrowFlag if given.

    @@ -1406,7 +1410,8 @@ for discussion).

    To invoke, given a struct, -event, and an optional legacyOutputDidListenersThrowFlag, run these steps: +event, phase, and an optional legacyOutputDidListenersThrowFlag, +run these steps:

    1. Set event's target to the target of the @@ -1432,7 +1437,7 @@ for discussion). run. Note that removal still has an effect due to the removed field.

    2. Let found be the result of running inner invoke with event, - listeners, and legacyOutputDidListenersThrowFlag if given. + listeners, phase, and legacyOutputDidListenersThrowFlag if given.

    3. If found is false and event's {{Event/isTrusted}} attribute is true, @@ -1456,7 +1461,7 @@ for discussion). "transitionend""webkitTransitionEnd" -

    4. Inner invoke with event, listeners, and +

    5. Inner invoke with event, listeners, phase, and legacyOutputDidListenersThrowFlag if given.

    6. Set event's {{Event/type}} attribute value to originalEventType. @@ -1464,7 +1469,7 @@ for discussion).

    To inner invoke, given an -event, listeners, and an optional +event, listeners, phase, and an optional legacyOutputDidListenersThrowFlag, run these steps:

      @@ -1480,13 +1485,11 @@ for discussion).
    1. Set found to true. -

    2. If event's {{Event/eventPhase}} attribute value is {{Event/CAPTURING_PHASE}} - and listener's capture is false, then - continue. +

    3. If phase is "capturing" and listener's + capture is false, then continue. -

    4. If event's {{Event/eventPhase}} attribute value is {{Event/BUBBLING_PHASE}} and - listener's capture is true, then - continue. +

    5. If phase is "bubbling" and listener's + capture is true, then continue.

    6. If listener's once is true, then remove listener from event's {{Event/currentTarget}} @@ -9983,6 +9986,7 @@ Mark Miller, Martijn van der Ven, Mats Palmgren, Mounir Lamouri, +Michael Stramel, Michaelâ„¢ Smith, Mike Champion, Mike Taylor,