diff --git a/dom.bs b/dom.bs index 9885e84c3..85cf9a6b4 100644 --- a/dom.bs +++ b/dom.bs @@ -486,7 +486,8 @@ empty list.
An event has an associated path. A path is a list of structs. Each struct consists of an -item (an {{EventTarget}} object), target (a +item (an {{EventTarget}} object), an +item-in-shadow-tree (a boolean), a target (a potential event target), a relatedTarget (a potential event target), a touch target list (a list @@ -742,6 +743,25 @@ method, when invoked, must run these steps:
incapable of setting {{Event/composed}}. It has to be supported for legacy content. ++partial interface Window { + [Replaceable] readonly attribute any event; // historical +}; ++ +
Each {{Window}} object has an associated current event (undefined or an +{{Event}} object). Unless stated otherwise it is undefined. + +
The event
attribute's getter, when invoked, must
+return the context object's current event.
+
+
Web developers are strongly encouraged to instead rely on {{Event}} object passed to +event listeners as that will result in more portable code. This attribute is not available in +workers or worklets, and is inaccurate for events dispatched in shadow trees. + +
@@ -1337,14 +1357,20 @@ for discussion). touchTargets, and a slot-in-closed-tree, run these steps:+
+ +Let item-in-shadow-tree be false. + +
If target is a node and its root is a + shadow root, then set item-in-shadow-tree to true. +
Let root-of-closed-tree be false.
If target is a shadow root whose mode is "
closed
", then set root-of-closed-tree to true.Append a new struct to event's path - whose item is target, target is - targetOverride, relatedTarget is relatedTarget, + whose item is target, item-in-shadow-tree is + item-in-shadow-tree, 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. @@ -1366,16 +1392,29 @@ for discussion).
If event's stop propagation flag is set, then return. -
Let object be tuple's item. +
Initialize event's {{Event/currentTarget}} attribute to tuple's + item.
- -
Let listeners be a clone of object's - event listener list. +
Let listeners be a clone of event's + {{Event/currentTarget}} attribute value'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. -
Initialize event's {{Event/currentTarget}} attribute to object. +
Let global be the current global object. + +
Let currentEvent be undefined. + +
- +
If global is a {{Window}} object, then: + +
+
Set currentEvent to global's current event. + +
If tuple's item-in-shadow-tree is false, then set + global's current event to event. +
Let found be the result of running inner invoke with event, listeners, and legacyOutputDidListenersThrowFlag if given. @@ -1407,6 +1446,9 @@ for discussion).
Set event's {{Event/type}} attribute value to originalEventType.
If global is a {{Window}} object, then set global's + current event to currentEvent.
To inner invoke, given an