This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 21066 - Provide an event path API
Summary: Provide an event path API
Status: RESOLVED FIXED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: HISTORICAL - Component Model (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Hayato Ito
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on: 23682
Blocks: 14978 18780
  Show dependency treegraph
 
Reported: 2013-02-21 02:29 UTC by Steve Orvell
Modified: 2015-04-15 06:10 UTC (History)
11 users (show)

See Also:


Attachments
event path use case (1.07 KB, text/html)
2013-03-20 23:56 UTC, Frankie Fu
Details

Description Steve Orvell 2013-02-21 02:29:08 UTC
It's a common practice to install an event listener on some ancestor node and interrogate the event target to discover some intermediate node of importance on which the event occurred. It's possible to install listeners on each of the intermediate nodes, but it's not efficient to do so.

Consider this setup: in a chess game, there's a <table> representing the board. Each cell can contain a piece and we need to know when the user clicks on a cell.  Instead of installing a click event listener on each of the 64 cells, we install one listener on the board <table> itself. The event target might be a piece and we crawl up the dom tree to find the cell that was clicked.

There's a problem with this approach when using shadowDOM. There is no convenient way in general to take an event target and crawl up the tree if doing so needs to traverse into shadowDOM. For example, let's imagine that the chess pieces are in the game element's light DOM and the board cells are in its shadowDOM. In this case event.target.parentNode will be the board itself so we cannot easily discover which cell was clicked.

One way to solve this problem is to provide an api for discovering the path of an event through a shadowRoot. This might return a node list of effective parents in the composed dom tree. For example, shadowRoot.pathForEvent(e) would in this case return: [e.target, cell, table, game's shadowRoot].
Comment 1 Olli Pettay 2013-02-21 09:35:42 UTC
But we want to hide the shadow dom from the rest of the page as much as 
possible. Otherwise shadow DOM becomes rather meaningless.
If the page outside the shadow DOM needs to know about the shadow DOM,
it feels like shadow DOM shouldn't be used at all for that use case.



(In Gecko there is privileged JS code only
EventTarget[] getEventTargetChain(), but that is for devtools and such)
Comment 2 Dimitri Glazkov 2013-02-21 16:25:06 UTC
This is an exciting proposal, but I think it belongs in DOM core. We should expose event path as Event.path.

To alleviate Olli's concerns, for Shadow DOM, the Event.path should be adjusted to show only the chunk of the path that's visible in the context of a given tree.
Comment 3 Anne 2013-02-22 12:14:40 UTC
If you expose just that though, you can find out the path yourself I think. We could consider adding that though.
Comment 4 Dimitri Glazkov 2013-02-22 17:07:44 UTC
(In reply to comment #3)
> If you expose just that though, you can find out the path yourself I think.
> We could consider adding that though.

You can only find the even path by building it, right? Since the tree could be mutated by event listeners, the path is unknowable until traveled.
Comment 5 Anne 2013-02-22 17:19:36 UTC
That is a good point, and although comment 0 did not describe that particular situation, it does make a slightly more convincing case.
Comment 6 Hayato Ito 2013-03-15 08:31:08 UTC
As explained in https://www.w3.org/Bugs/Public/show_bug.cgi?id=21067, it looks to me that it is good enough to have getDistributedParent() API rather than event.path to address the use case of #c0.
Comment 7 Frankie Fu 2013-03-20 23:56:29 UTC
Created attachment 1343 [details]
event path use case
Comment 8 Steve Orvell 2013-04-22 14:07:20 UTC
(In reply to comment #6)
> As explained in https://www.w3.org/Bugs/Public/show_bug.cgi?id=21067, it
> looks to me that it is good enough to have getDistributedParent() API rather
> than event.path to address the use case of #c0.

insertionParent is not sufficient because it does not account for re-distribution.

This is noted in https://www.w3.org/Bugs/Public/show_bug.cgi?id=21067#c11
Comment 9 Steve Orvell 2013-04-22 14:10:11 UTC
Oops, I meant that insertionParent is not sufficient because it does not account for *reprojection*.
Comment 10 Olli Pettay 2013-04-22 14:12:25 UTC
(In reply to comment #8)
> insertionParent is not sufficient because it does not account for
> re-distribution.
> 
> This is noted in https://www.w3.org/Bugs/Public/show_bug.cgi?id=21067#c11

Not sure I understand that comment. insertionParent should return the same
object which is the parent in the event target chain.
Comment 11 Steve Orvell 2013-04-22 14:37:59 UTC
Given:
<a>
  <d>
SR
  <b>
    <content id="a">
  SR
  <c>  
    <content id="b">

The unflattened tree is:

<a>
  <b>
    <c>
      <content id="b">
        <content id="a">
          <d>

In the current implementation of insertionParent in blink, the insertionParent of <d> is content#b. Thus, one cannot see content#a in the event path. Perhaps we need a more precise definition of insertionParent.
Comment 12 Dimitri Glazkov 2013-04-22 16:45:36 UTC
Intuitively, insertionParent should return a value that would allow its consumer to reconstruct the composed tree. Otherwise, the consumer will be sad.
Comment 13 Scott Miles 2013-04-22 18:06:41 UTC
At one point Erik and I proved that there was no way to define an insertionParent that could reconstruct the event path. Unfortunately we did that in chat, and I don't remember the details. I will talk to him and try to rebuild that argument.
Comment 14 Dominic Cooney 2013-04-23 01:50:07 UTC
(In reply to comment #11)
> Given:
> <a>
>   <d>
> SR
>   <b>
>     <content id="a">
>   SR
>   <c>  
>     <content id="b">
> 
> The unflattened tree is:
> 
> <a>
>   <b>
>     <c>
>       <content id="b">
>         <content id="a">
>           <d>
> 
> In the current implementation of insertionParent in blink, the
> insertionParent of <d> is content#b. Thus, one cannot see content#a in the
> event path. Perhaps we need a more precise definition of insertionParent.

The implementation in Blink seems wrong to me. I think <d>.insertionParent should be #a; #a.insertionParent should be #b; and all other .insertionParent null.
Comment 15 Dimitri Glazkov 2013-04-23 01:56:51 UTC
(In reply to comment #14)

> The implementation in Blink seems wrong to me. I think <d>.insertionParent
> should be #a; #a.insertionParent should be #b; and all other
> .insertionParent null.

+1. I think .insertionParent should be sufficient to reconstruct the event path. Everything else seems like a bug. But Hayato-san spent a lot more time thinking on this. I want him to chime in with buckets of wisdom.
Comment 16 Steve Orvell 2013-04-24 02:37:43 UTC
InsertionParent cannot be used to generate the event path. Here's an example:

<a>
	<span id=”one” />
	<span id=”two” />
SR-a
	<b>
		<content id=”contentA”></content>
	SR-b
		<content id=”contentB” select=”#one”></content>
		<content id=”contentB2” select=”#two”></content>


click -> #one:
#one
[contentA]
[contentB]
SR-b
b
SR-a
a

click -> #two:
#two
[contentA]
[contentB2]
SR-b
b
SR-a
a

#contentA's insertionParent cannot be both #contentB and #contentB2.
Comment 17 Hayato Ito 2013-04-24 09:10:18 UTC
(In reply to comment #16)
> InsertionParent cannot be used to generate the event path. Here's an example:
> 
> <a>
> 	<span id=”one” />
> 	<span id=”two” />
> SR-a
> 	<b>
> 		<content id=”contentA”></content>
> 	SR-b
> 		<content id=”contentB” select=”#one”></content>
> 		<content id=”contentB2” select=”#two”></content>
> 
> 
> click -> #one:
> #one
> [contentA]
> [contentB]
> SR-b
> b
> SR-a
> a
> 
> click -> #two:
> #two
> [contentA]
> [contentB2]
> SR-b
> b
> SR-a
> a
> 
> #contentA's insertionParent cannot be both #contentB and #contentB2.

That's right. That's the reason we cannot use the current implementation of element.insertionParent() to emulate event.path as I noted in https://www.w3.org/Bugs/Public/show_bug.cgi?id=21067#c11

- event.path should contain insertion points, which does not appear in the flattened tree.
  The current element.insertionParent() cannot be used to traverse all insertion points in case of reprojection.
- We need a *context* to determine insertionPoint.insertionParent().
  e.g. To determine #contentA's insertionParent, we need an additional context (from where we are starting a path).
  In the above case, the context is #one or #two.

One idea is to make insertionParent() take additional parameter.

For example:
   contentA.insertionParent(#one) -> contentB
   contentA.insertionParent(#two) -> contentB2

Now, event.path can be emulated:

  var originalEventTarget = ....; // #one or #two
  var element = originalEventTarget;
  var eventPath = [element];
  while (element.insertionParent(originalEventTarget)) {
     element = element.insertionParent(originalEventTarget);
     // element might be an 'insertion point' in this case.
     eventPath.push(element);
  }

WDYT? Is this a reasonable API?
Comment 18 Hayato Ito 2013-04-24 09:26:41 UTC
(In reply to comment #17)
> One idea is to make insertionParent() take additional parameter.
> 
> For example:
>    contentA.insertionParent(#one) -> contentB
>    contentA.insertionParent(#two) -> contentB2
> 
> Now, event.path can be emulated:
> 
>   var originalEventTarget = ....; // #one or #two
>   var element = originalEventTarget;
>   var eventPath = [element];
>   while (element.insertionParent(originalEventTarget)) {
>      element = element.insertionParent(originalEventTarget);
>      // element might be an 'insertion point' in this case.
>      eventPath.push(element);
>   }
> 
> WDYT? Is this a reasonable API?

My initial feeling is that this is not good API since it is likely to be misused.
Just providing event.path API is much better.
Comment 19 Anne 2013-04-24 13:26:11 UTC
Metapoint: It sounds like when we have time we should start looking into what parts of Shadow DOM should move into DOM proper and what parts need to be described elsewhere. Though that depends on how stable the proposed Shadow DOM API is in general of course.
Comment 20 Scott Miles 2013-04-24 16:29:36 UTC
Fwiw, I agree with Hayato-san.

I worry that the 'event.path' emulation code will become boilerplate that many components will include.
Comment 21 Dimitri Glazkov 2013-04-24 16:42:33 UTC
(In reply to comment #20)
> Fwiw, I agree with Hayato-san.
> 
> I worry that the 'event.path' emulation code will become boilerplate that
> many components will include.

I am convinced.

(In reply to comment #19)
> Metapoint: It sounds like when we have time we should start looking into
> what parts of Shadow DOM should move into DOM proper and what parts need to
> be described elsewhere. Though that depends on how stable the proposed
> Shadow DOM API is in general of course.

Anne, I totally agree. Can we maybe discuss this at TPAC tomorrow/Friday?
Comment 22 Dimitri Glazkov 2013-04-24 18:19:43 UTC
(In reply to comment #21)
> 
> (In reply to comment #19)
> > Metapoint: It sounds like when we have time we should start looking into
> > what parts of Shadow DOM should move into DOM proper and what parts need to
> > be described elsewhere. Though that depends on how stable the proposed
> > Shadow DOM API is in general of course.

BTW, I think the easy steps here are:

1) in DOM spec, add event.path and  simply say that it returns a copy of the event path
2) in shadow DOM spec, tweak event handling section to explicitly mention that it modifies how an event path is built.
Comment 23 Olli Pettay 2013-04-24 20:09:55 UTC
If many components need event path, there is something wrong with components spec. Components should be able to work without too much knowledge about the
things outside them, and normal DOM shouldn't need to care about Shadow DOM.

(In reply to comment #22)
> 1) in DOM spec, add event.path and  simply say that it returns a copy of the
> event path
> 2) in shadow DOM spec, tweak event handling section to explicitly mention
> that it modifies how an event path is built.
Sounds doable, though I don't know whether we want event.path
or someEventTarget.path("eventType") or some such.
Comment 24 Scott Miles 2013-04-24 22:29:15 UTC
Components need to be able to work with elements that are supplied to them from the outside and projected into shadow-dom (aka distributed elements). Those elements have different positions in the tree depending on your point of reference. 

In general, components (internally) need event.path in order to process events that have bubbled up from distributed elements. I don't believe there is any encapsulation problem here.

The alternative is attaching listeners explicitly to all possible useful targets, which can be extremely inefficient (see first note in this thread).
Comment 25 Hayato Ito 2013-05-14 06:09:01 UTC
FYI.

I've landed an experimental Event Path API in blink.

- https://codereview.chromium.org/14508005/
- https://chromiumcodereview.appspot.com/15063004/
Comment 26 Erik Arvidsson 2013-05-23 09:23:24 UTC
The name of this is bad. Methods should not be nouns. This should be a getter named `path` or the method should be renamed to something else.
Comment 27 Dimitri Glazkov 2013-05-23 14:45:23 UTC
(In reply to comment #26)
> The name of this is bad. Methods should not be nouns. This should be a
> getter named `path` or the method should be renamed to something else.

That's a mistake on my part. I should've caught this in review. I totally assumed Hayato-san was just using a property, since that's what I meant it to be in the first place.
Comment 28 Hayato Ito 2013-05-31 05:30:29 UTC
I've updated the spec.

https://dvcs.w3.org/hg/webcomponents/diff/614b6b7050c0/spec/shadow/index.html
Comment 29 Anne 2013-06-21 01:38:39 UTC
If you don't want this in DOM after all, please do fix the component first. If you do, don't mark it fixed ;-)
Comment 30 Dimitri Glazkov 2013-06-21 02:51:08 UTC
(In reply to comment #29)
> If you don't want this in DOM after all, please do fix the component first.
> If you do, don't mark it fixed ;-)

hurdur!
Comment 31 Anne 2013-07-09 15:43:02 UTC
So why does this return a NodeList? Should this not return a JavaScript frozen (static) Array?
Comment 32 Olli Pettay 2013-07-09 16:46:34 UTC
Uh, NodeList is very wrong. It should be an array of EventTargets.
Comment 33 Hayato Ito 2013-07-10 03:36:38 UTC
Could you help me to understand that?
I guess each item in the *list* is not always a Node, right?
That might be something which extends EventTarget.

(In reply to comment #32)
> Uh, NodeList is very wrong. It should be an array of EventTargets.
Comment 34 Anne 2013-07-10 12:38:26 UTC
Right, XMLHttpRequest is not a Node, Indexed DB has a tree of non-Node EventTarget objects, etc.
Comment 35 Erik Arvidsson 2013-07-10 14:30:45 UTC
Also, should Window be included in the path for an event generetated on a Node in the document? Internally for the shadow dom polyfill I keep it in the list but I had to remove from it before returning the event.path to match Blink.
Comment 36 Anne 2013-07-10 14:41:51 UTC
Right, Window is another good point as to why NodeList is a bad idea. It should be there.
Comment 37 Hayato Ito 2013-07-11 04:35:13 UTC
(In reply to comment #34)
> Right, XMLHttpRequest is not a Node, Indexed DB has a tree of non-Node
> EventTarget objects, etc.

Thank you.

I've checked the spec here.
http://dom.spec.whatwg.org/#dispatching-events
> 5.7.4 - If event's target attribute value is participating in a tree, let event path be a static ordered list of all its ancestors in tree order, and let event path be the empty list otherwise.

An event path only includes *something* which can participate in a tree. I assumed that it's always a Node since whatever participates in a *DOM tree* is always a Node.

If index-db has a tree of EventTargets, I think we cannot use NodeList here.
That makes sense. Let's change that to an array of EventTargets if there is no objection.
Comment 38 Hayato Ito 2013-07-11 04:37:19 UTC
(In reply to comment #36)
> Right, Window is another good point as to why NodeList is a bad idea. It
> should be there.

I don't think Window should be included since it doesn't participate in a tree.
Comment 39 Olli Pettay 2013-07-11 12:56:22 UTC
window is part of the event target chain, so it definitely should be there.
Comment 40 Anne 2013-07-11 13:39:04 UTC
Indeed, HTML says it participates in that tree and indeed events fired on nodes reach Window so it *has* to participate.
Comment 41 Olli Pettay 2013-07-11 13:40:56 UTC
(there is one special case when events dispatched to a document which has .defaultView don't reach the window, and that is 'load'. Load event doesn't propagate from document to window.)
Comment 42 Dimitri Glazkov 2014-03-21 17:34:04 UTC
This got lost. Discussion ends abruptly nearly a year ago.
Comment 43 Anne 2014-03-24 11:59:10 UTC
Let's get the patch in the Shadow DOM specification fixed first before considering how to integrate this into DOM.
Comment 44 Hayato Ito 2014-05-29 06:19:37 UTC
(In reply to Anne from comment #43)
> Let's get the patch in the Shadow DOM specification fixed first before
> considering how to integrate this into DOM.

The patch has already gotten in the Shadow DOM spec.
Is it a time to integrate this into DOM?
Comment 45 Anne 2014-05-30 13:58:43 UTC
(In reply to Hayato Ito from comment #44)
> The patch has already gotten in the Shadow DOM spec.
> Is it a time to integrate this into DOM?

Comment 40 does not seem fixed yet?
Comment 46 Anne 2014-05-30 14:46:00 UTC
Also, to better set expectations. I don't have a good plan for integrating shadow DOM throughout the existing ecosystem yet. Some of it is extensions to HTML and some of it is new DOM bits, not quite sure how to deal with that.
Comment 47 Hayato Ito 2014-06-02 05:05:04 UTC
(In reply to Anne from comment #45)
> (In reply to Hayato Ito from comment #44)
> > The patch has already gotten in the Shadow DOM spec.
> > Is it a time to integrate this into DOM?
> 
> Comment 40 does not seem fixed yet?

Agreed. Reopening this issue loos reasonable.

I am afraid that I need your help to understand how Window object participates in the tree. I appreciate where I can know how Window object participates in the tree.

I've read the following part:
http://www.whatwg.org/specs/web-apps/current-work/multipage/browsers.html#the-window-object

1. I am assuming that Document is the root of the node tree until now. Can I assume that?
2. Should I consider Window object is the parent of the Document?
3. Is there any better interpretation? I'd like to avoid 'Windows is the parent of Document' if we could.
Comment 48 Anne 2014-06-02 08:19:50 UTC
I think the way to understand this is that you need to understand that the event path != node tree. Since you edit the shadow tree specification, that should be somewhat obvious ;-)

Now with the exception of events whose type is load, in the event path the Window object follows document.

Another way of saying this is that for the purposes of events, Window is the root of the node tree (unless event.type is "load").
Comment 49 Hayato Ito 2014-12-12 06:50:26 UTC
Thank you. I am triaging issues in the Shadow DOM spec.

I think this issue can be actionable and can be fixed.

Of course, as we know, in Blink, a Window object has been receiving events so far. The current Shadow DOM spec and the implementation differs. I'd like to fix this. The blink's implementation won't change.

However, event.path will become to includes Window object at the beginning of that as a result. This is the only user visible change, I think.

We might have a plan B:
   event.path API return EventTarget[] where Window object is removed from the event path.

If someone have a strong concern about the compatibility and prefer plan B, please let me know that.
Comment 50 Hayato Ito 2014-12-12 13:13:36 UTC
Partially fixed.
https://github.com/w3c/webcomponents/commit/73b64edd930a623616923c9cfc0f118fc8cc6abc

Note that the case of "event.type is 'load'"  is not yet considered.
Comment 51 Koji Ishii 2015-01-09 06:51:20 UTC
(In reply to Hayato Ito from comment #49)
> 
> However, event.path will become to includes Window object at the beginning
> of that as a result. This is the only user visible change, I think.

and change the type to an array of EventTarget, right?

> We might have a plan B:
>    event.path API return EventTarget[] where Window object is removed from
> the event path.
> 
> If someone have a strong concern about the compatibility and prefer plan B,
> please let me know that.

I actually prefer this, not from the compatibility, but because I cannot see any useful cases of having window in event.path API.

I think the Shadow DOM spec is fine either way, since it's talking about how the actual event path is, but when we add the API to the DOM spec, we could simply say "window object is not included in the returned array from the event.path property."

Thoughts?
Comment 52 Anne 2015-01-09 06:54:51 UTC
I don't understand why we'd want to exclude the Window object. When it's part of the event path, it would make sense to include it.
Comment 53 Koji Ishii 2015-01-11 14:19:59 UTC
(In reply to Anne from comment #52)
> I don't understand why we'd want to exclude the Window object. When it's
> part of the event path, it would make sense to include it.

I'm ok with that. My thought is that, if the API creates an array everytime it's read, not including unuseful staff may be better, but it's just mild preference.

Anne, now that comment 40 is done, can you update the DOM spec? Should Hayato or I propose a patch to the whatwg/html-mirror?
Comment 54 Olli Pettay 2015-01-11 17:42:30 UTC
(In reply to Koji Ishii from comment #53)
> I'm ok with that. My thought is that, if the API creates an array everytime
> it's read, not including unuseful staff may be better, but it's just mild
> preference.

How is Window object less useful than, say Document object or document root or body element for example?
Note, usually event handlers (onfoo DOM attributes) in body element are actually added to the Window object.
Comment 55 Koji Ishii 2015-01-13 01:08:56 UTC
Thanks Olli, understood.

Since a patch might be too much for this case, here's the suggested text for all to review:

| readonly attribute sequence<EventTarget> path;
|
| Returns a list of EventTarget this event goes through in the order it bubbles.

Since Window object should be included unless specified not to, I didn't put in, but we could add a note if desired.

Does this definition and text look good? If so, I can go and fix Blink to match to this.
Comment 56 Koji Ishii 2015-01-13 13:20:47 UTC
FYI, a PR for web-platform-tests is on its way:
https://github.com/w3c/web-platform-tests/pull/1524/files
Comment 57 Anne 2015-01-13 15:37:18 UTC
A fix for DOM would be somewhat more complex I think. We need to flush out the definition of path so it's crystal clear.

Also, this makes it return an array, correct? And mutating that array won't have any effect on anything? I think that's fine... (There's some talk over in IDL land about being able to return frozen array objects for cases like this...)
Comment 58 Hayato Ito 2015-01-13 23:26:19 UTC
(In reply to Anne from comment #57)
> A fix for DOM would be somewhat more complex I think. We need to flush out
> the definition of path so it's crystal clear.
> 
> Also, this makes it return an array, correct? And mutating that array won't
> have any effect on anything? I think that's fine... (There's some talk over
> in IDL land about being able to return frozen array objects for cases like
> this...)

Yeah, mutation shouldn't have any effect. The returned *array-like* should not be a   live array. That's my intention.

Does a frozen array mean the array itself can't be modified?

e.g

var path = event.path;
path[0] = 'a'; // => This throws an exception.
path.push('a'); // This also throws an exception.
Comment 59 Koji Ishii 2015-01-14 05:46:15 UTC
Must be very clear to people here, but what I learnt yesterday from our IDL guy
was that sequence<T> is always passed by value, while T[] is always passed by
reference as defined in http://www.w3.org/TR/WebIDL/#idl-sequence

So making the type "sequence<EventTarget>" rather than "EventTarget[]"
should imply that mutating that array won't have any effect on anything in my
understanding.

Do you prefer to be more verbose on that point rather than implying it from the
type? Or am I incorrect to assume that sequence<T> implies that?

Also anything else you think the suggested text above is missing?

I looked at Event IDL: https://dom.spec.whatwg.org/#interface-event
and most methods/attributes are not very verbose, but your advice for how to
make crystal clearer would be appreciated. Oftentimes what's not clear is not
clear for who wrote the text.
Comment 60 Hayato Ito 2015-01-14 05:55:13 UTC
(In reply to Koji Ishii from comment #59)
> Must be very clear to people here, but what I learnt yesterday from our IDL
> guy
> was that sequence<T> is always passed by value, while T[] is always passed by
> reference as defined in http://www.w3.org/TR/WebIDL/#idl-sequence
> 
> So making the type "sequence<EventTarget>" rather than "EventTarget[]"
> should imply that mutating that array won't have any effect on anything in my
> understanding.
> 
> Do you prefer to be more verbose on that point rather than implying it from
> the
> type? Or am I incorrect to assume that sequence<T> implies that?
> 
> Also anything else you think the suggested text above is missing?
> 
> I looked at Event IDL: https://dom.spec.whatwg.org/#interface-event
> and most methods/attributes are not very verbose, but your advice for how to
> make crystal clearer would be appreciated. Oftentimes what's not clear is not
> clear for who wrote the text.

According to the comment, https://www.w3.org/Bugs/Public/show_bug.cgi?id=25458#c5, Sequence<T> doesn't work for attributes.
Comment 61 Koji Ishii 2015-01-14 06:35:15 UTC
(In reply to Hayato Ito from comment #60)
> 
> According to the comment,
> https://www.w3.org/Bugs/Public/show_bug.cgi?id=25458#c5, Sequence<T> doesn't
> work for attributes.

Ah! Thank you, I missed that. By re-reading the spec, I found the source:
http://www.w3.org/TR/WebIDL/#idl-sequence

]]]
Sequences must not be used as the type of an attribute, constant or exception
field.

Note
This restriction exists so that it is clear to specification writers and API
users that sequences are copied rather than having references to them passed
around. Instead of a writable attribute of a sequence type, it is suggested
that a pair of operations to get and set the sequence is used. Another option
is to use an array type, which can be used as the type of an attribute.
[[[

Earlier in this thread preferred an attribute than an operation, so we use
array, but clarify in the spec that it returns a copy everytime. Understood.
Comment 62 Koji Ishii 2015-01-14 08:09:25 UTC
Should have read though bug 25458 before posting, so you want a type for event.path.

From curiosity, why is T[] going away? Because of lack of interoperablity?
Comment 63 Anne 2015-01-14 09:54:48 UTC
(In reply to Koji Ishii from comment #62)
> From curiosity, why is T[] going away? Because of lack of interoperablity?

I recommend reading bug 23682. We'll have to wait for that to be sorted in some manner. I believe heycam plans to tackle that next.
Comment 64 Koji Ishii 2015-01-15 01:45:20 UTC
Got it, thank you for the pointer. That's very clear.

It looks like we're heading to B), correct?
  readonly attribute FrozenArray<Gamepad> gamepads;

Look forward to it being resolved, but in the meantime, what do you prefer?

We're:
- event.path is nowhere in the spec. Events in shadow is in the shadow spec, but this is DOM API that could work without shadow DOM involved (though not useful), and we're stuck.
- Blink still implements NodeList without window included.
- Gecko is trying to follow the Blink behavior by explicitly removing window from the list.

Options for the spec updates:
A) Keep this undocumented until bug 23682 is resolved.
B) Put a tentative one once in Shadow DOM spec with the issue marked, then move to DOM when bug 23682 is resolved.
C) Put a tentative one to DOM spec and update when bug 23682 is resolved.

Since T[] is much closer to FrozenArray<T> than NodeList is, and it looks like not having window is troubling Gecko, I think impl could update to T[] to include window then update again when bug 23682 is done.
Comment 65 Hayato Ito 2015-01-15 05:21:45 UTC
(In reply to Koji Ishii from comment #64)
> Got it, thank you for the pointer. That's very clear.
> 
> It looks like we're heading to B), correct?
>   readonly attribute FrozenArray<Gamepad> gamepads;
> 
> Look forward to it being resolved, but in the meantime, what do you prefer?
> 
> We're:
> - event.path is nowhere in the spec. Events in shadow is in the shadow spec,
> but this is DOM API that could work without shadow DOM involved (though not
> useful), and we're stuck.

I'm afraid I don't understand what is a real issue here. UA can provide event.path API without any Shadow DOM implementation, can't we?

> - Blink still implements NodeList without window included.
> - Gecko is trying to follow the Blink behavior by explicitly removing window
> from the list.

Gecko doesn't have to follow the current Blink behavior. The current spec already includes Window in event path.

> 
> Options for the spec updates:
> A) Keep this undocumented until bug 23682 is resolved.
> B) Put a tentative one once in Shadow DOM spec with the issue marked, then
> move to DOM when bug 23682 is resolved.

Shadow DOM spec mentions this issue of IDL as 'ISSUE 1'. Is it different from plan B?

> C) Put a tentative one to DOM spec and update when bug 23682 is resolved.
> 
> Since T[] is much closer to FrozenArray<T> than NodeList is, and it looks
> like not having window is troubling Gecko, I think impl could update to T[]
> to include window then update again when bug 23682 is done.
Comment 66 Koji Ishii 2015-01-15 06:13:32 UTC
Never mind, didn't find event.path in the Shadow DOM spec and thought it's not in, sorry about the noise. So we're in B. Thanks.
Comment 67 Hayato Ito 2015-04-15 06:10:36 UTC
Let me close this bug because all issues were resolved or filed as a separate bug. Let's focus each bug separately and close this bug.