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
<p> The <dfnclass=css-codedata-dfn-type=at-ruledata-export="" id=at-ruledef-scope>@scope<aclass=self-linkhref=#at-ruledef-scope></a></dfn> at-rule allows authors to create scoped style rules using CSS syntax.
193
193
The syntax of the <aclass=cssdata-link-type=maybehref=#at-ruledef-scopetitle=@scope>@scope</a> rule is:
<p> where the elements matched by the <aclass="production css-code" data-link-type=typehref=http://dev.w3.org/csswg/selectors-4/#ltselectortitle="<selector>"><selector></a>
199
+
<p> where the elements matched by the <aclass="production css-code" data-link-type=typehref=http://dev.w3.org/csswg/selectors-4/#typedef-selectortitle="<selector>"><selector></a>
200
200
are <adata-link-type=dfnhref=http://dev.w3.org/csswg/selectors-4/#scoping-roottitle="scoping roots">scoping roots</a> for the style rules in <aclass="production css-code" data-link-type=typehref=http://dev.w3.org/csswg/css-syntax-3/#typedef-stylesheettitle="<stylesheet>"><stylesheet></a>,
201
201
and selectors of style rules scoped by <aclass=cssdata-link-type=maybehref=#at-ruledef-scopetitle=@scope>@scope</a> are
202
-
<adata-link-type=dfnhref=http://dev.w3.org/csswg/selectors-4/#scope-contained-selectorstitle=scope-contained>scope-contained</a> to their <adata-link-type=dfnhref=http://dev.w3.org/csswg/selectors-4/#scoping-roottitle="scoping root">scoping root</a>.
202
+
<adata-link-type=dfnhref=http://dev.w3.org/csswg/selectors-4/#scope-contained-title=scope-contained>scope-contained</a> to their <adata-link-type=dfnhref=http://dev.w3.org/csswg/selectors-4/#scoping-roottitle="scoping root">scoping root</a>.
203
203
204
-
<p> If multiple elements match the <aclass="production css-code" data-link-type=typehref=http://dev.w3.org/csswg/selectors-4/#ltselectortitle="<selector>"><selector></a>,
This rule makes it very easy for authors to create scoped style sheets,
206
+
which could affect the optimization strategies for implementing scoped styles.
207
+
208
+
<p> If multiple elements match the <aclass="production css-code" data-link-type=typehref=http://dev.w3.org/csswg/selectors-4/#typedef-selectortitle="<selector>"><selector></a>,
205
209
the <aclass="production css-code" data-link-type=typehref=http://dev.w3.org/csswg/css-syntax-3/#typedef-stylesheettitle="<stylesheet>"><stylesheet></a> is effectively duplicated
206
210
and scoped independently to each one.
207
211
Authors should avoid using overly-generic selectors
<pre>:scope-context(<aclass="production css-code" data-link-type=typehref=http://dev.w3.org/csswg/selectors-4/#ltselectortitle="<selector>"><selector></a>) div {...}
283
-
scope(<aclass="production css-code" data-link-type=typehref=http://dev.w3.org/csswg/selectors-4/#ltselectortitle="<selector>"><selector></a>) div {...}
284
-
\scope <aclass="production css-code" data-link-type=typehref=http://dev.w3.org/csswg/selectors-4/#ltselectortitle="<selector>"><selector></a>\ div {...}
285
-
<aclass="production css-code" data-link-type=typehref=http://dev.w3.org/csswg/selectors-4/#ltselectortitle="<selector>"><selector></a> \scope\ div {...}
289
+
<pre>:scope-context(<aclass="production css-code" data-link-type=typehref=http://dev.w3.org/csswg/selectors-4/#typedef-selectortitle="<selector>"><selector></a>) div {...}
290
+
scope(<aclass="production css-code" data-link-type=typehref=http://dev.w3.org/csswg/selectors-4/#typedef-selectortitle="<selector>"><selector></a>) div {...}
291
+
\scope <aclass="production css-code" data-link-type=typehref=http://dev.w3.org/csswg/selectors-4/#typedef-selectortitle="<selector>"><selector></a>\ div {...}
292
+
<aclass="production css-code" data-link-type=typehref=http://dev.w3.org/csswg/selectors-4/#typedef-selectortitle="<selector>"><selector></a> \scope\ div {...}
286
293
</pre>
287
294
<p> This functionality would replace <spanclass=cssdata-link-type=maybetitle=@global>@global</span>, which is a poor excuse for a selector.
Selecting Into the Light: the <aclass=cssdata-link-type=maybehref=#selectordef-host0title=:host>:host</a>, <aclass=cssdata-link-type=maybehref=#selectordef-hosttitle=:host()>:host()</a>, and <aclass=cssdata-link-type=maybehref=#selectordef-host-contexttitle=:host-context()>:host-context()</a> pseudo-classes</span><aclass=self-linkhref=#host-selector></a></h4>
<p> The <dfnclass=css-codedata-dfn-type=selectordata-export="" id=selectordef-host>:host()<aclass=self-linkhref=#selectordef-host></a></dfn> function pseudo-class
<p> When evaluated in the context of a <adata-link-type=dfnhref=#shadow-treetitle="shadow tree">shadow tree</a>,
418
430
it matches the <adata-link-type=dfnhref=#shadow-treetitle="shadow tree’s">shadow tree’s</a><adata-link-type=dfnhref=#host-element0title="host element">host element</a>
419
431
if the <adata-link-type=dfnhref=#host-element0title="host element">host element</a>,
<p> When evaluated in the context of a <adata-link-type=dfnhref=#shadow-treetitle="shadow tree">shadow tree</a>,
465
477
the <aclass=cssdata-link-type=maybehref=#selectordef-host-contexttitle=:host-context()>:host-context()</a> pseudo-class matches the <adata-link-type=dfnhref=#host-element0title="host element">host element</a>,
466
-
if the <adata-link-type=dfnhref=#host-element0title="host element">host element</a> or one of its ancestors matches the provided <aclass="production css-code" data-link-type=typehref=http://dev.w3.org/csswg/selectors-4/#ltcompound-selectortitle="<compound-selector>"><compound-selector></a>.
478
+
if the <adata-link-type=dfnhref=#host-element0title="host element">host element</a> or one of its ancestors matches the provided <aclass="production css-code" data-link-type=typehref=http://dev.w3.org/csswg/selectors-4/#typedef-compound-selectortitle="<compound-selector>"><compound-selector></a>.
<divdata-fill-with=normative-references><dl><dtid=css21title=CSS21><aclass=self-linkhref=#css21></a>[CSS21]<dd>Bert Bos; et al. <ahref=http://www.w3.org/TR/2011/REC-CSS2-20110607>Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification</a>. 7 June 2011. W3C Recommendation. URL: <ahref=http://www.w3.org/TR/2011/REC-CSS2-20110607>http://www.w3.org/TR/2011/REC-CSS2-20110607</a><dtid=css3cascadetitle=CSS3CASCADE><aclass=self-linkhref=#css3cascade></a>[CSS3CASCADE]<dd>Håkon Wium Lie; Elika J. Etemad; Tab Atkins Jr.. <ahref=http://www.w3.org/TR/2013/CR-css-cascade-3-20131003/>CSS Cascading and Inheritance Level 3</a>. 3 October 2013. W3C Candidate Recommendation. (Work in progress.) URL: <ahref=http://www.w3.org/TR/2013/CR-css-cascade-3-20131003/>http://www.w3.org/TR/2013/CR-css-cascade-3-20131003/</a><dtid=domtitle=DOM><aclass=self-linkhref=#dom></a>[DOM]<dd>Anne van Kesteren; et al. <ahref=http://www.w3.org/TR/2012/WD-dom-20121206/>DOM4</a>. 6 December 2012. W3C Working Draft. (Work in progress.) URL: <ahref=http://www.w3.org/TR/2012/WD-dom-20121206/>http://www.w3.org/TR/2012/WD-dom-20121206/</a><dtid=rfc2119title=RFC2119><aclass=self-linkhref=#rfc2119></a>[RFC2119]<dd>S. Bradner. <ahref=http://www.ietf.org/rfc/rfc2119.txt>Key words for use in RFCs to Indicate Requirement Levels</a>. URL: <ahref=http://www.ietf.org/rfc/rfc2119.txt>http://www.ietf.org/rfc/rfc2119.txt</a></dl></div>
1011
+
<divdata-fill-with=normative-references><dl><dtid=css21title=CSS21><aclass=self-linkhref=#css21></a>[CSS21]<dd>Bert Bos; et al. <ahref=http://www.w3.org/TR/2011/REC-CSS2-20110607>Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification</a>. 7 June 2011. W3C Recommendation. URL: <ahref=http://www.w3.org/TR/2011/REC-CSS2-20110607>http://www.w3.org/TR/2011/REC-CSS2-20110607</a><dtid=css3cascadetitle=CSS3CASCADE><aclass=self-linkhref=#css3cascade></a>[CSS3CASCADE]<dd>Håkon Wium Lie; Elika J. Etemad; Tab Atkins Jr.. <ahref=http://www.w3.org/TR/2013/CR-css-cascade-3-20131003/>CSS Cascading and Inheritance Level 3</a>. 3 October 2013. W3C Candidate Recommendation. (Work in progress.) URL: <ahref=http://www.w3.org/TR/2013/CR-css-cascade-3-20131003/>http://www.w3.org/TR/2013/CR-css-cascade-3-20131003/</a><dtid=domtitle=DOM><aclass=self-linkhref=#dom></a>[DOM]<dd>Anne van Kesteren; Aryeh Gregor; Ms2ger. <ahref=http://dom.spec.whatwg.org/>DOM Living Standard</a>. WHATWG Living Standard. (Work in progress.) URL: <ahref=http://dom.spec.whatwg.org/>http://dom.spec.whatwg.org/</a><dtid=rfc2119title=RFC2119><aclass=self-linkhref=#rfc2119></a>[RFC2119]<dd>S. Bradner. <ahref=http://www.ietf.org/rfc/rfc2119.txt>Key words for use in RFCs to Indicate Requirement Levels</a>. URL: <ahref=http://www.ietf.org/rfc/rfc2119.txt>http://www.ietf.org/rfc/rfc2119.txt</a></dl></div>
This would be defined similarly to <aclass=cssdata-link-type=maybehref=#selectordef-host-contexttitle=:host-context()>:host-context()</a>,
1029
1053
but matching the ancestors of the <adata-link-type=dfnhref=http://dev.w3.org/csswg/selectors-4/#scoping-roottitle="scoping root">scoping root</a> instead.
<pre>:scope-context(<aclass="production css-code" data-link-type=typehref=http://dev.w3.org/csswg/selectors-4/#ltselectortitle="<selector>"><selector></a>) div {...}
1038
-
scope(<aclass="production css-code" data-link-type=typehref=http://dev.w3.org/csswg/selectors-4/#ltselectortitle="<selector>"><selector></a>) div {...}
1039
-
\scope <aclass="production css-code" data-link-type=typehref=http://dev.w3.org/csswg/selectors-4/#ltselectortitle="<selector>"><selector></a>\ div {...}
1040
-
<aclass="production css-code" data-link-type=typehref=http://dev.w3.org/csswg/selectors-4/#ltselectortitle="<selector>"><selector></a> \scope\ div {...}
1061
+
<pre>:scope-context(<aclass="production css-code" data-link-type=typehref=http://dev.w3.org/csswg/selectors-4/#typedef-selectortitle="<selector>"><selector></a>) div {...}
1062
+
scope(<aclass="production css-code" data-link-type=typehref=http://dev.w3.org/csswg/selectors-4/#typedef-selectortitle="<selector>"><selector></a>) div {...}
1063
+
\scope <aclass="production css-code" data-link-type=typehref=http://dev.w3.org/csswg/selectors-4/#typedef-selectortitle="<selector>"><selector></a>\ div {...}
1064
+
<aclass="production css-code" data-link-type=typehref=http://dev.w3.org/csswg/selectors-4/#typedef-selectortitle="<selector>"><selector></a> \scope\ div {...}
1041
1065
</pre>
1042
1066
<p> This functionality would replace <spanclass=cssdata-link-type=maybetitle=@global>@global</span>, which is a poor excuse for a selector.
1043
1067
</p><ahref=#issue-aecbd194> ↵ </a></div>
1044
1068
1045
1069
<divclass=issue>
1070
+
This section is still under discussion.
1071
+
Feedback and advice on intuitive syntax for the following functionality
0 commit comments