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 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. +
Let touchTargets be a new list. -
Append to an event path with event, target, - targetOverride, relatedTarget, and false. +
For each touchTarget of event's + touch target list, append the result of retargeting + touchTarget against target to touchTargets. -
Let isActivationEvent be true, if event is a {{MouseEvent}} object and
- event's {{Event/type}} attribute is "click
", and false otherwise.
+
Append to an event path with event, target, + targetOverride, relatedTarget, touchTargets, and false. -
Let activationTarget be target, if isActivationEvent is - true and target has activation behavior, and null otherwise. +
Let isActivationEvent be true, if event is a {{MouseEvent}} object
+ and event's {{Event/type}} attribute is "click
", and false otherwise.
-
Let slotable be target, if target is - assigned, and null otherwise. +
If isActivationEvent is true and target has + activation behavior, then set activationTarget to + target. -
Let slot-in-closed-tree be false. +
Let slotable be target, if target is a slotable + and is assigned, and null otherwise. -
Let parent be the result of invoking target's get the parent - with event. +
Let slot-in-closed-tree be false. -
While parent is non-null:
+Let parent be the result of invoking target's get the parent + with event. -
If slotable is non-null: +
While parent is non-null:
Assert: parent is a slot. - -
Set slotable to null. +
If slotable is non-null: -
If parent's root is a shadow root whose
- mode is "closed
", then set slot-in-closed-tree to
- true.
-
Assert: parent is a slot. -
If parent is assigned, then set slotable to - parent. +
Set slotable to null. -
Let relatedTarget be the result of retargeting event's - relatedTarget against parent if event's - relatedTarget is non-null, and null otherwise. +
If parent's root is a shadow root whose
+ mode is "closed
", then set slot-in-closed-tree
+ to true.
+
If target's root is a - shadow-including inclusive ancestor of parent, then: +
If parent is a slotable and is assigned, then set + slotable to parent. -
If isActivationEvent is true, event's {{Event/bubbles}} attribute - is true, activationTarget is null, and parent has - activation behavior, then set activationTarget to - parent. +
Let relatedTarget be the result of retargeting event's + relatedTarget against parent. -
Append to an event path with event, parent, null, - relatedTarget, and slot-in-closed-tree. -
Let touchTargets be a new list. -
Otherwise, if parent and relatedTarget are identical, then set - parent to null. +
For each touchTarget of event's + touch target list, append the result of retargeting + touchTarget against parent to touchTargets. -
Otherwise, set target to parent and then: +
If parent is a node and target's root is a + shadow-including inclusive ancestor of parent, then: -
If isActivationEvent is true, activationTarget is null, and - target has activation behavior, then set - activationTarget to target. +
If isActivationEvent is true, event's {{Event/bubbles}} + attribute is true, activationTarget is null, and parent has + activation behavior, then set activationTarget to + parent. -
Append to an event path with event, parent, - target, relatedTarget, and slot-in-closed-tree. -
Append to an event path with event, parent, null, + relatedTarget, touchTargets, and slot-in-closed-tree. +
If parent is non-null, then set parent to the result of invoking - parent's get the parent with event. +
Otherwise, if parent is relatedTarget, then set parent + to null. -
Set slot-in-closed-tree to false. -
Otherwise, set target to parent and then: -
Set event's {{Event/eventPhase}} attribute to {{Event/CAPTURING_PHASE}}. +
If isActivationEvent is true, activationTarget is null, and + target has activation behavior, then set + activationTarget to target. -
If activationTarget is non-null and activationTarget has - legacy-pre-activation behavior, then run activationTarget's - legacy-pre-activation behavior. +
Append to an event path with event, parent, + target, relatedTarget, touchTargets, and + slot-in-closed-tree. +
For each tuple in event's path, in reverse order: +
If parent is non-null, then set parent to the result of invoking + parent's get the parent with event. -
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. +
Set slot-in-closed-tree to false. +
Set event's relatedTarget to tuple's - relatedTarget. +
Let clearTargetsTuple be the last tuple in event's + path whose target is non-null. -
Run the retargeting steps with event. +
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. -
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. -
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. +
For each tuple in event's path, in reverse order: -
Set event's relatedTarget to tuple's - relatedTarget. +
-Run the retargeting steps with event. +
For each tuple in event's path, in order: -
If tuple's target is non-null, then set event's - {{Event/eventPhase}} attribute to {{Event/AT_TARGET}}. +
If tuple's target is non-null, then set + event's {{Event/eventPhase}} attribute to {{Event/AT_TARGET}}. -
Otherwise, set event's {{Event/eventPhase}} attribute to - {{Event/BUBBLING_PHASE}}. +
Otherwise, set event's {{Event/eventPhase}} attribute to + {{Event/BUBBLING_PHASE}}. -
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. +
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. +
Set event's {{Event/target}} attribute to null. -
Set event's {{Event/currentTarget}} attribute to null. +
Set event's relatedTarget to null. -
Set event's path to the empty list. +
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:Let root-of-closed-tree be false. @@ -1326,22 +1347,32 @@ for discussion).
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:
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. + +
Set event's relatedTarget to tuple's + relatedTarget. + +
Set event's touch target list to tuple's + touch target list. +
If event's stop propagation flag is set, then return. -
Let listeners be a new list. +
Let object be tuple's item.
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:
If A's root is not a shadow root, or A's - root is a shadow-including inclusive ancestor of B, then return - A. +
If one of the following is true + +
then return A.