You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<li><ahref=#inheritance><spanclass=secno>4</span> Shadow DOM Combinators</a>
119
119
<ulclass=toc>
120
120
<li><ahref=#shadow-combinator><spanclass=secno>4.1</span> Selecting Into A Shadow Tree: the <spanclass=cssdata-link-type=maybetitle=/shadow/>/shadow/</span> combinator</a>
121
-
<li><ahref=#shadow-child-combinator><spanclass=secno>4.2</span> Selecting the Top-level Elements in a Shadow Tree: the <spanclass=cssdata-link-type=maybetitle=/shadow-child/>/shadow-child/</span> combinator</a>
122
-
<li><ahref=#shadow-deep-combinator><spanclass=secno>4.3</span> Selecting Through All Shadows: the <spanclass=cssdata-link-type=maybetitle=/shadow-deep/>/shadow-deep/</span> combinator</a>
123
-
<li><ahref=#content-combinator><spanclass=secno>4.4</span> Selecting Distributed Elements: the <spanclass=cssdata-link-type=maybetitle=/content/>/content/</span> combinator</a></ul>
121
+
<li><ahref=#shadow-deep-combinator><spanclass=secno>4.2</span> Selecting Through All Shadows: the <spanclass=cssdata-link-type=maybetitle=/shadow-deep/>/shadow-deep/</span> combinator</a>
122
+
<li><ahref=#content-combinator><spanclass=secno>4.3</span> Selecting Distributed Elements: the <spanclass=cssdata-link-type=maybetitle=/content/>/content/</span> combinator</a></ul>
124
123
<li><ahref=#selectors><spanclass=secno>5</span> Shadow DOM Selectors</a>
125
124
<ulclass=toc>
126
125
<li><ahref=#top-selector><spanclass=secno>5.1</span> Selecting Root-like Elements: the <spanclass=cssdata-link-type=maybetitle=:top>:top</span> pseudo-class</a>
127
126
<li><ahref=#host-selector><spanclass=secno>5.2</span> Selecting the Host Element: the <spanclass=cssdata-link-type=maybetitle=:host>:host</span> and <spanclass=cssdata-link-type=maybetitle=:host()>:host()</span> pseudo-classes</a>
128
-
<li><ahref=#ancestor-selector><spanclass=secno>5.3</span> Selecting Based on an Ancestor Outside the Shadow Tree: the <spanclass=cssdata-link-type=maybetitle=:ancestor()>:ancestor()</span> pseudo-class</a></ul>
127
+
<li><ahref=#ancestor-selector><spanclass=secno>5.3</span> Selecting Based on an Ancestor Outside the Shadow Tree: the <spanclass=cssdata-link-type=maybetitle=:ancestor()>:ancestor()</span> pseudo-class</a>
128
+
<li><ahref=#shadow-pseudoelement><spanclass=secno>5.4</span> Selecting the Shadow Root Itself: the <spanclass=cssdata-link-type=maybetitle=::shadow>::shadow</span> pseudo-element</a></ul>
129
129
<li><ahref=#cascading><spanclass=secno>6</span> Changes to the Cascading Model</a>
Selecting Into A Shadow Tree: the <aclass=cssdata-link-type=maybehref=#selectordef-shadowtitle=/shadow/>/shadow/</a> combinator</span><aclass=self-linkhref=#shadow-combinator></a></h3>
281
+
Selecting Into A Shadow Tree: the <aclass=cssdata-link-type=maybehref=#selectordef-shadow0title=/shadow/>/shadow/</a> combinator</span><aclass=self-linkhref=#shadow-combinator></a></h3>
282
282
283
-
<p> When a <dfnclass=css-codedata-dfn-type=selectordata-export="" id=selectordef-shadow>/shadow/<aclass=self-linkhref=#selectordef-shadow></a></dfn> combinator is encountered in a selector,
283
+
<p> When a <dfnclass=css-codedata-dfn-type=selectordata-export="" id=selectordef-shadow0>/shadow/<aclass=self-linkhref=#selectordef-shadow0></a></dfn> combinator is encountered in a selector,
284
284
first filter the <adata-link-type=dfnhref=http://dev.w3.org/csswg/selectors-4/#selector-match-listtitle="selector match list">selector match list</a> to only include elements with <adata-link-type=dfnhref=#shadow-treetitle="shadow trees">shadow trees</a>.
285
285
Then replace every element in the <adata-link-type=dfnhref=http://dev.w3.org/csswg/selectors-4/#selector-match-listtitle="selector match list">selector match list</a>
286
286
with the <adata-link-type=dfnhref=#top-level-elementtitle="top-level elements">top-level elements</a> of each <adata-link-type=dfnhref=#shadow-treetitle="shadow tree">shadow tree</a> of the element,
as that element is further nested in the <adata-link-type=dfnhref=#shadow-treetitle="shadow tree">shadow tree</a> of the <code><x-bar></code> component.
Selecting the Top-level Elements in a Shadow Tree: the <aclass=cssdata-link-type=maybehref=#selectordef-shadow-childtitle=/shadow-child/>/shadow-child/</a> combinator</span><aclass=self-linkhref=#shadow-child-combinator></a></h3>
316
-
317
-
<p> When a <dfnclass=css-codedata-dfn-type=selectordata-export="" id=selectordef-shadow-child>/shadow-child/<aclass=self-linkhref=#selectordef-shadow-child></a></dfn> combinator is encountered in a selector,
318
-
first filter the <adata-link-type=dfnhref=http://dev.w3.org/csswg/selectors-4/#selector-match-listtitle="selector match list">selector match list</a> to only include elements with <adata-link-type=dfnhref=#shadow-treetitle="shadow trees">shadow trees</a>.
319
-
Then replace every element in the <adata-link-type=dfnhref=http://dev.w3.org/csswg/selectors-4/#selector-match-listtitle="selector match list">selector match list</a>
320
-
with the <adata-link-type=dfnhref=#top-level-elementtitle="top-level elements">top-level elements</a> of each <adata-link-type=dfnhref=#shadow-treetitle="shadow tree">shadow tree</a> of the element.
321
-
322
-
<divclass=example>
323
-
For example, say you had a component with a <adata-link-type=dfnhref=#shadow-treetitle="shadow tree">shadow tree</a> like the following:
but not <spanclass=cssdata-link-type=maybetitle=#not-top>#not-top</span>,
337
-
because it’s not a <adata-link-type=dfnhref=#top-level-elementtitle="top-level element">top-level element</a> in the <adata-link-type=dfnhref=#shadow-treetitle="shadow tree">shadow tree</a>.
338
-
339
-
<p> If one wanted to target <spanclass=cssdata-link-type=maybetitle=#not-top>#not-top</span>,
340
-
one way to do it would be with <spanclass=cssdata-link-type=maybetitle="x-foo /shadow-child/ div > span">x-foo /shadow-child/ div > span</span>.
Selecting Through All Shadows: the <aclass=cssdata-link-type=maybehref=#selectordef-shadow-deeptitle=/shadow-deep/>/shadow-deep/</a> combinator</span><aclass=self-linkhref=#shadow-deep-combinator></a></h3>
350
316
351
317
<p> When a <dfnclass=css-codedata-dfn-type=selectordata-export="" id=selectordef-shadow-deep>/shadow-deep/<aclass=self-linkhref=#selectordef-shadow-deep></a></dfn> combinator is encountered in a selector,
Selecting Distributed Elements: the <aclass=cssdata-link-type=maybehref=#selectordef-contenttitle=/content/>/content/</a> combinator</span><aclass=self-linkhref=#content-combinator></a></h3>
381
347
382
348
<p> When a <dfnclass=css-codedata-dfn-type=selectordata-export="" id=selectordef-content>/content/<aclass=self-linkhref=#selectordef-content></a></dfn> combinator is encountered in a selector,
Selecting the Shadow Root Itself: the <aclass=cssdata-link-type=maybehref=#selectordef-shadowtitle=::shadow>::shadow</a> pseudo-element</span><aclass=self-linkhref=#shadow-pseudoelement></a></h3>
483
+
484
+
<p> If an element has at least one <adata-link-type=dfnhref=#shadow-treetitle="shadow tree">shadow tree</a>,
485
+
the <dfnclass=css-codedata-dfn-type=selectordata-export="" id=selectordef-shadow>::shadow<aclass=self-linkhref=#selectordef-shadow></a></dfn> pseudo-element selects the <adata-link-type=dfnhref=#shadow-treetitle="shadow trees">shadow trees</a> themselves.
486
+
In HTML, the <adata-link-type=dfnhref=#shadow-treetitle="shadow tree">shadow tree</a> is represented by <aclass=idl-codedata-link-type=interfacetitle=shadowroot>ShadowRoot</a> objects.
487
+
488
+
<p> The <aclass=cssdata-link-type=maybehref=#selectordef-shadowtitle=::shadow>::shadow</a> pseudo-element must not generate boxes,
489
+
unless specified otherwise in another specification.
490
+
However, for the purpose of Selectors,
491
+
the <aclass=cssdata-link-type=maybehref=#selectordef-shadowtitle=::shadow>::shadow</a> pseudo-element is considered to be the root of the <adata-link-type=dfnhref=#shadow-treetitle="shadow tree">shadow tree</a>,
492
+
with the <adata-link-type=dfnhref=#top-level-elementtitle="top-level elements">top-level elements</a> in the <adata-link-type=dfnhref=#shadow-treetitle="shadow tree">shadow tree</a> the direct children of the <aclass=cssdata-link-type=maybehref=#selectordef-shadowtitle=::shadow>::shadow</a> pseudo-element.
493
+
494
+
<divclass=example>
495
+
For example, say you had a component with a <adata-link-type=dfnhref=#shadow-treetitle="shadow tree">shadow tree</a> like the following:
but not <spanclass=cssdata-link-type=maybetitle=#not-top>#not-top</span>,
509
+
because it’s not a <adata-link-type=dfnhref=#top-level-elementtitle="top-level element">top-level element</a> in the <adata-link-type=dfnhref=#shadow-treetitle="shadow tree">shadow tree</a>.
510
+
511
+
<p> If one wanted to target <spanclass=cssdata-link-type=maybetitle=#not-top>#not-top</span>,
512
+
one way to do it would be with <spanclass=cssdata-link-type=maybetitle="x-foo::shadow > div > span">x-foo::shadow > div > span</span>.
513
+
However, this introduces a strong dependency on the internal structure of the component;
514
+
in most cases, it’s better to use the <aclass=cssdata-link-type=maybehref=#selectordef-shadow0title=/shadow/>/shadow/</a> combinator,
515
+
like <spanclass=cssdata-link-type=maybetitle="x-foo /shadow/ span">x-foo /shadow/ span</span>,
516
+
to select all the elements of some type in the <adata-link-type=dfnhref=#shadow-treetitle="shadow tree">shadow tree</a>.
0 commit comments