W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2015

RE: [Shadow] Q: Removable shadows (and an idea for lightweight shadows)?

From: Travis Leithead <travis.leithead@microsoft.com>
Date: Thu, 26 Mar 2015 20:23:16 +0000
To: Elliott Sprehn <esprehn@chromium.org>
CC: Justin Fagnani <justinfagnani@google.com>, "Dimitri Glazkov (dglazkov@google.com)" <dglazkov@google.com>, Arron Eicholz <arronei@microsoft.com>, "Anne van Kesteren (annevk@annevk.nl)" <annevk@annevk.nl>, Ryosuke Niwa <rniwa@apple.com>, WebApps WG <public-webapps@w3.org>
Message-ID: <BLUPR03MB38955195FFD5791A5497418F8080@BLUPR03MB389.namprd03.prod.outlook.com>
You make a series of excellent points.

In the sense that you have a new set of nodes to manage holistically, then having some sort of “document” container does makes sense for that (a ShadowRoot) in order to place all your search/navigation APIs.

You got me thinking though—getElementById is currently not available on ShadowRoot right? Does that API in the host’s document find IDs in the shadow? I presume not given the guidelines you mentioned. I wonder what other APIs from Document are desired?

Back to the original question though… is removal of previously-created shadow roots something that makes sense?

From: Elliott Sprehn [mailto:esprehn@chromium.org]
Sent: Thursday, March 26, 2015 12:59 PM
To: Travis Leithead
Cc: Justin Fagnani; Dimitri Glazkov (dglazkov@google.com); Arron Eicholz; Anne van Kesteren (annevk@annevk.nl); Ryosuke Niwa; WebApps WG
Subject: Re: [Shadow] Q: Removable shadows (and an idea for lightweight shadows)?

On Thu, Mar 26, 2015 at 11:36 AM, Travis Leithead <travis.leithead@microsoft.com<mailto:travis.leithead@microsoft.com>> wrote:
> From: Justin Fagnani [mailto:justinfagnani@google.com<mailto:justinfagnani@google.com>]
>> Elements expose this “shadow node list” via APIs that are very similar to
>> existing node list management, e.g., appendShadowChild(), insertShadowBefore(),
>> removeShadowChild(), replaceShadowChild(), shadowChildren[], shadowChildNodes[].
>This part seems like a big step back to me. Shadow roots being actual nodes means
>that existing code and knowledge work against them.

"existing code and knowledge work against them" -- I'm not sure you understood correctly.
Nodes in the "shadow child list" wouldn't show up in the childNodes list, nor in any of the
node traversal APIs (e.g., not visible to qSA, nextSibling, previousSibling, children, childNodes,

Trivially speaking, if you wanted to hide two divs that implement a "stack panel" and have some
element render it, you'd just do:

Those divs would not be discoverable by any traditional DOM APIs (they would now be on the
"shadow side"), and the only way to see/use them would be to use the new element.shadowChildren

But perhaps I'm misunderstanding your point.

>The API surface that you'd have to duplicate with shadow*() methods would be quite large.

That's true. Actually, I think the list above is probably about it.

So if I want to query down into those children I need to do element.shadowFirstChild.querySelectorAll or shadowFirstChild.getElementById? That requires looking at all siblings in the shadowChildList, so I suppose you'd want shadowQuerySelector, shadowGetElementById, etc? You also need to duplicate elementFromPoint (FromRect, etc.) down to Element/Text or add special shadow* versions since right now they only exist on Document and ShadowRoot.

I have to admit I have an allergic reaction to having an element like <div id="foo"> and then doing element.parentNode.querySelector("#foo") != div.

Another fundamental requirement of Shadow DOM is that you never accidentally "fall out" or "fall into" a shadow and must always take an explicit step to get there. Having shadow node's parentNode be the host breaks that.

We could make the parentNode be null like ShadowRoot of today, but you're still stuck adding API duplication or writing code to iterate the shadowChildren list.

- E
Received on Thursday, 26 March 2015 20:23:58 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:27:26 UTC