From 58b19e4aa89ab0c6ef998daa455dcbb189423cf8 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Thu, 12 May 2016 11:40:32 +0200 Subject: [PATCH] Shadow: define Event's composedPath() Fixes #242. Also reverts https://github.com/w3c/webcomponents/issues/432 as it appears to no longer be needed. If we ever have an event path that starts with a non-node and ends with a node we'll have to add that complexity back. (The reason it is named composedPath() is because deepPath() and various other names were no longer viable after Chrome's initial experiment. See the various issues.) --- dom.bs | 36 ++++++++++++++++++++++++++++++++++++ dom.html | 29 ++++++++++++++++++++++++++++- 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/dom.bs b/dom.bs index f68abb40..98d7a160 100644 --- a/dom.bs +++ b/dom.bs @@ -613,6 +613,7 @@ interface Event { readonly attribute DOMString type; readonly attribute EventTarget? target; readonly attribute EventTarget? currentTarget; + sequence<EventTarget> composedPath(); const unsigned short NONE = 0; const unsigned short CAPTURING_PHASE = 1; @@ -671,6 +672,12 @@ list of tuples, each of which consists of an item (an {{EventTarget}} obj
Returns the object whose event listener's callback is currently being invoked. +
event . {{Event/composedPath()}} +
Returns the item objects of event's path (objects on which + listeners will be invoked), except for any nodes in shadow trees of which the + shadow root's mode is "closed" that are not + reachable from event's {{Event/currentTarget}}. +
event . {{Event/eventPhase}}
Returns the event's phase, which is one of {{Event/NONE}}, {{Event/CAPTURING_PHASE}}, @@ -733,6 +740,29 @@ attributes must return the values they were initialized to. When an event is created the attributes must be initialized to null. +

The composedPath() method, when invoked, must run these +steps: + +

    +
  1. Let composedPath be a new empty list. + +

  2. Let currentTarget be context object's currentTarget + attribute value. + +

  3. +

    For each tuple in context object's path: + +

    1. If currentTarget is a node and tuple's item is an + unclosed node of currentTarget, or currentTarget is not a + node, then append tuple's item to composedPath.

    + +
  4. Return composedPath. +

+ +

This algorithm assumes that when the target argument to the +dispatch algorithm is not a node, none of the tuples in event argument's +eventual path will contain a node either. + The eventPhase attribute must return the value it was initialized to, which must be one of the following: @@ -5476,6 +5506,12 @@ is an object or one of its shadow-including descendants. shadow-including inclusive ancestor is an object or one of its shadow-including ancestors. +

A node A is an unclosed node of a +node B, if A's root is a +shadow-including inclusive ancestor of B, or A's root +is a shadow root whose mode is "open" and +host is an unclosed node of B. +


For now you can find more information about this object in diff --git a/dom.html b/dom.html index b630625f..c03adf4d 100644 --- a/dom.html +++ b/dom.html @@ -71,7 +71,7 @@

DOM

-

Living Standard — Last Updated

+

Living Standard — Last Updated

@@ -492,6 +492,7 @@

type; readonly attribute EventTarget? target; readonly attribute EventTarget? currentTarget; + sequence<EventTarget> composedPath(); const unsigned short NONE = 0; const unsigned short CAPTURING_PHASE = 1; @@ -538,6 +539,10 @@

currentTarget
Returns the object whose event listener’s callback is currently being invoked. +
event . composedPath() +
Returns the item objects of event’s path (objects on which + listeners will be invoked), except for any nodes in shadow trees of which the shadow root’s mode is "closed" that are not + reachable from event’s currentTarget.
event . eventPhase
Returns the event’s phase, which is one of NONE, CAPTURING_PHASE, AT_TARGET, and BUBBLING_PHASE.
event . stopPropagation() @@ -573,6 +578,24 @@

target and currentTarget attributes must return the values they were initialized to. When an event is created the attributes must be initialized to null.

+

The composedPath() method, when invoked, must run these +steps:

+
    +
  1. +

    Let composedPath be a new empty list.

    +
  2. +

    Let currentTarget be context object’s currentTarget attribute value.

    +
  3. +

    For each tuple in context object’s path:

    +
      +
    1. +

      If currentTarget is a node and tuple’s item is an unclosed node of currentTarget, or currentTarget is not a node, then append tuple’s item to composedPath.

      +
    +
  4. +

    Return composedPath.

    +
+

This algorithm assumes that when the target argument to the dispatch algorithm is not a node, none of the tuples in event argument’s +eventual path will contain a node either.

The eventPhase attribute must return the value it was initialized to, which must be one of the following:

@@ -3233,6 +3256,7 @@

A shadow-including inclusive descendant is an object or one of its shadow-including descendants.

An object A is a shadow-including ancestor of an object B, if and only if B is a shadow-including descendant of A.

A shadow-including inclusive ancestor is an object or one of its shadow-including ancestors.

+

A node A is an unclosed node of a node B, if A’s root is a shadow-including inclusive ancestor of B, or A’s root is a shadow root whose mode is "open" and host is an unclosed node of B.


For now you can find more information about this object in Shadow DOM. The DOM Standard will be updated over time to cover more details.

@@ -5500,6 +5524,7 @@

attribute for Event, in §3.2
  • composed flag, in §3.2 +
  • composedPath(), in §3.2
  • constructor, in §3.4
  • contained, in §5.2
  • contains(other), in §4.4 @@ -6186,6 +6211,7 @@

    dfn for Document, in §4.5
  • TypeInfo, in §8.2 +
  • unclosed node, in §4.8
  • update steps, in §7.1
  • URL @@ -6396,6 +6422,7 @@

    I readonly attribute DOMString type; readonly attribute EventTarget? target; readonly attribute EventTarget? currentTarget; + sequence<EventTarget> composedPath(); const unsigned short NONE = 0; const unsigned short CAPTURING_PHASE = 1;