diff --git a/dom.bs b/dom.bs index 0238ee1a8..f8a97a777 100644 --- a/dom.bs +++ b/dom.bs @@ -466,24 +466,30 @@ dictionary EventInit {

An {{Event}} object is simply named an event. It allows for signaling that something has occurred, e.g., that an image has completed downloading.

-

An event has an associated relatedTarget (null or an -{{EventTarget}} object). Unless stated otherwise it is null.

+

A potential event target is null or an {{EventTarget}} object. -

Other specifications use relatedTarget to define a +

An event has an associated relatedTarget (a +potential event target). Unless stated otherwise it is null. + +

Other specifications use relatedTarget to define a relatedTarget attribute. [[UIEVENTS]] +

An event has an associated touch target list (a +list of zero or more potential event targets). Unless stated otherwise it is the +empty list. + +

The touch target list is for the exclusive use of defining the +{{TouchEvent}} interface and related interfaces. [[TOUCH-EVENTS]] +

An event has an associated path. A path is a list of structs. Each struct consists of an -item (an {{EventTarget}} object), target (null -or an {{EventTarget}} object), a relatedTarget (null or an -{{EventTarget}} object), root-of-closed-tree (a boolean), and a -slot-in-closed-tree (a boolean). A path is initially the -empty list.

- -

Specifications may define -retargeting steps for all or some events. -The algorithm is passed event, as indicated in the dispatch -algorithm below. +item (an {{EventTarget}} object), target (a +potential event target), a +relatedTarget (a +potential event target), a touch target list (a list +of potential event targets), a root-of-closed-tree (a boolean), and +a slot-in-closed-tree (a boolean). A path is initially +the empty list.

event = new Event(type [, eventInitDict]) @@ -1154,149 +1160,164 @@ for discussion).

legacy target override flag is only used by HTML and only when target is a {{Window}} object. -

  • Let relatedTarget be the result of retargeting event's - relatedTarget against target if event's - relatedTarget is non-null, and null otherwise. +
  • Let activationTarget be null. + +

  • Let relatedTarget be the result of retargeting event's + relatedTarget against target. + +

  • +

    If target is not relatedTarget or target is event's + relatedTarget, then: -

  • If target is relatedTarget and target is not - event's relatedTarget, then return true. +

      +
    1. Let touchTargets be a new list. -

    2. Append to an event path with event, target, - targetOverride, relatedTarget, and false. +

    3. For each touchTarget of event's + touch target list, append the result of retargeting + touchTarget against target to touchTargets. -

    4. Let isActivationEvent be true, if event is a {{MouseEvent}} object and - event's {{Event/type}} attribute is "click", and false otherwise. +

    5. Append to an event path with event, target, + targetOverride, relatedTarget, touchTargets, and false. -

    6. Let activationTarget be target, if isActivationEvent is - true and target has activation behavior, and null otherwise. +

    7. Let isActivationEvent be true, if event is a {{MouseEvent}} object + and event's {{Event/type}} attribute is "click", and false otherwise. -

    8. Let slotable be target, if target is - assigned, and null otherwise. +

    9. If isActivationEvent is true and target has + activation behavior, then set activationTarget to + target. -

    10. Let slot-in-closed-tree be false. +

    11. Let slotable be target, if target is a slotable + and is assigned, and null otherwise. -

    12. Let parent be the result of invoking target's get the parent - with event. +

    13. Let slot-in-closed-tree be false. -

    14. -

      While parent is non-null:

      +
    15. Let parent be the result of invoking target's get the parent + with event. -

      1. -

        If slotable is non-null: +

        While parent is non-null:

          -
        1. Assert: parent is a slot. - -

        2. Set slotable to null. +

        3. +

          If slotable is non-null: -

        4. If parent's root is a shadow root whose - mode is "closed", then set slot-in-closed-tree to - true. -

        +
          +
        1. Assert: parent is a slot. -

        2. If parent is assigned, then set slotable to - parent. +

        3. Set slotable to null. -

        4. Let relatedTarget be the result of retargeting event's - relatedTarget against parent if event's - relatedTarget is non-null, and null otherwise. +

        5. If parent's root is a shadow root whose + mode is "closed", then set slot-in-closed-tree + to true. +

        -
      2. -

        If target's root is a - shadow-including inclusive ancestor of parent, then: +

      3. If parent is a slotable and is assigned, then set + slotable to parent. -

          -
        1. If isActivationEvent is true, event's {{Event/bubbles}} attribute - is true, activationTarget is null, and parent has - activation behavior, then set activationTarget to - parent. +

        2. Let relatedTarget be the result of retargeting event's + relatedTarget against parent. -

        3. Append to an event path with event, parent, null, - relatedTarget, and slot-in-closed-tree. -

        +
      4. Let touchTargets be a new list. -

      5. Otherwise, if parent and relatedTarget are identical, then set - parent to null. +

      6. For each touchTarget of event's + touch target list, append the result of retargeting + touchTarget against parent to touchTargets. -

      7. -

        Otherwise, set target to parent and then: +

      8. +

        If parent is a node and target's root is a + shadow-including inclusive ancestor of parent, then: -

          -
        1. If isActivationEvent is true, activationTarget is null, and - target has activation behavior, then set - activationTarget to target. +

            +
          1. If isActivationEvent is true, event's {{Event/bubbles}} + attribute is true, activationTarget is null, and parent has + activation behavior, then set activationTarget to + parent. -

          2. Append to an event path with event, parent, - target, relatedTarget, and slot-in-closed-tree. -

          +
        2. Append to an event path with event, parent, null, + relatedTarget, touchTargets, and slot-in-closed-tree. +

        -
      9. If parent is non-null, then set parent to the result of invoking - parent's get the parent with event. +

      10. Otherwise, if parent is relatedTarget, then set parent + to null. -

      11. Set slot-in-closed-tree to false. -

      +
    16. +

      Otherwise, set target to parent and then: -

    17. Set event's {{Event/eventPhase}} attribute to {{Event/CAPTURING_PHASE}}. +

        +
      1. If isActivationEvent is true, activationTarget is null, and + target has activation behavior, then set + activationTarget to target. -

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

      3. Append to an event path with event, parent, + target, relatedTarget, touchTargets, and + slot-in-closed-tree. +

      -
    18. -

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

    19. If parent is non-null, then set parent to the result of invoking + parent's get the parent with event. -

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

      2. Set slot-in-closed-tree to false. +

      -
    20. Set event's relatedTarget to tuple's - relatedTarget. +

    21. Let clearTargetsTuple be the last tuple in event's + path whose target is non-null. -

    22. Run the retargeting steps with event. +

    23. 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. -

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

    +
  • Set event's {{Event/eventPhase}} attribute to {{Event/CAPTURING_PHASE}}. -

  • -

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

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

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

    2. +

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

    3. Set event's relatedTarget to tuple's - relatedTarget. +

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

      -
    4. Run the retargeting steps with event. +

    5. +

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

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

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

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

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

      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 tuple's - item with event and legacyOutputDidListenersThrowFlag if given. +

      5. 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. +

    +
  • Set event's {{Event/eventPhase}} attribute to {{Event/NONE}}. + +

  • Set event's {{Event/currentTarget}} attribute to null. + +

  • Set event's path to the empty list. +

  • Unset event's dispatch flag, stop propagation flag, and stop immediate propagation flag. -

  • Set event's {{Event/eventPhase}} attribute to {{Event/NONE}}. +

  • +

    If clearTargets, then: -

  • If {{Event/target}}'s root is a shadow root, then set - event's {{Event/target}} attribute and event's relatedTarget - to null. +

      +
    1. Set event's {{Event/target}} attribute to null. -

    2. Set event's {{Event/currentTarget}} attribute to null. +

    3. Set event's relatedTarget to null. -

    4. Set event's path to the empty list. +

    5. Set event's touch target list to the empty list. +

  • If activationTarget is non-null, then: @@ -1314,8 +1335,8 @@ for discussion).

    To append to an event path, given an -event, target, targetOverride, relatedTarget, and a -slot-in-closed-tree, run these steps:

    +event, target, targetOverride, relatedTarget, +touchTargets, and a slot-in-closed-tree, run these steps:

    1. Let root-of-closed-tree be false. @@ -1326,22 +1347,32 @@ for discussion).

    2. Append a new struct to event's path whose item is target, target is targetOverride, relatedTarget is relatedTarget, + touch target list is touchTargets, root-of-closed-tree is root-of-closed-tree, and slot-in-closed-tree is slot-in-closed-tree.

    -

    To invoke an object with -event and an optional legacyOutputDidListenersThrowFlag, run these steps: +

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

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

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

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

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

    5. Let listeners be a new list. +

    6. Let object be tuple's item.

    7. -

      For each listener of object's - event listener list, append listener to - listeners. +

      Let listeners be a clone of object's + event listener list.

      This avoids event listeners added after this point from being run. Note that removal still has an effect due to the removed field. @@ -5621,9 +5652,17 @@ is an object or one of its shadow-including ancestors. B, repeat these steps until they return an object:

        -
      1. If A's root is not a shadow root, or A's - root is a shadow-including inclusive ancestor of B, then return - A. +

      2. +

        If one of the following is true + +

        + +

        then return A.

      3. Set A to A's root's host.

      @@ -9820,6 +9859,7 @@ Tab Atkins, Takashi Sakamoto, Takayoshi Kochi, Theresa O'Connor, +Theodore Dubois, timeless, Timo Tijhof, Tobie Langel,