@@ -261,20 +261,26 @@ Scoping Styles: the ''@scope'' rule</h3>
261261 For example,
262262 an author might have wide-reaching color-scheme scopes,
263263 which overlap more narrowly-scoped design patterns
264- such as a media object:
264+ such as a media object.
265+ The selectors in the ''@scope'' rule
266+ establish [=scoping root=] and optional [=scoping limit=] elements,
267+ while the nested selectors only match elements
268+ that are [=in scope|in a resulting scope=] :
265269
266270 <pre class=lang-css>
267271 @scope (.light-scheme) {
272+ /* Only match links inside a light-scheme */
268273 a { color: darkmagenta; }
269274 }
270275
271276 @scope (.dark-scheme) {
277+ /* Only match links inside a dark-scheme */
272278 a { color: plum; }
273279 }
274280
275281 @scope (.media-object) {
276- .media-image { border-radius: 50%; }
277- .media-content { padding: 1em ; }
282+ /* Only match author images inside a media-object */
283+ .author-image { border-radius: 50% ; }
278284 }
279285 </pre>
280286 </div>
@@ -299,29 +305,10 @@ Scoping Styles: the ''@scope'' rule</h3>
299305
300306 Issue: Should scoping limits be added to the definition of [=scoped selectors=] ?
301307
302- <div class=example>
303- [=Scoping limits=] can use the '':scope'' pseudo-class
304- to require a specific relationship to the [=scoping root=] :
305-
306- <pre class=lang-css>
307- /* .content is only a limit when it is a direct child of the :scope */
308- @scope (.media-object) to (:scope > .content) { ... }
309- </pre>
310-
311- [=Scoping limits=] can also reference elements outside their [=scoping root=]
312- by using '':scope'' .
313- For example:
314-
315- <pre class=lang-css>
316- /* .content is only a limit when the :scope is inside .sidebar */
317- @scope (.media-object) to (.sidebar :scope .content) { ... }
318- </pre>
319- </div>
320308
321309<h4 id="scope-effects">
322310Effects of ''@scope''</h4>
323311
324-
325312 The ''@scope'' [=at-rule=] has three primary effects
326313 on the [=style rules=] it contains:
327314
@@ -356,72 +343,6 @@ Effects of ''@scope''</h4>
356343 selectors within an ''@scope'' rule
357344 do not acquire the specificity of any parent selector(s) in the ''@scope'' prelude.
358345
359- <h4 id="scope-syntax">
360- Syntax of ''@scope''</h4>
361-
362- The syntax of the ''@scope'' rule is:
363-
364- <pre class="prod def">
365- @scope [(<<scope-start>> )]? [to (<<scope-end>> )]? {
366- <<stylesheet>>
367- }
368- </pre>
369-
370- where:
371-
372- * <dfn><<scope-start>></dfn> is a <<forgiving-selector-list>> [=selector=]
373- used to identify the [=scoping root=] (s).
374- * <dfn><<scope-end>></dfn> is a <<forgiving-selector-list>> [=selector=]
375- used to identify any [=scoping limits=] .
376- * the <<stylesheet>> represents the [=scoped style rules=] .
377-
378- [=Pseudo-elements=] cannot be [=scoping roots=] or [=scoping limits=] ;
379- they are invalid both within <<scope-start>> and <<scope-end>> .
380-
381- <h4 id="scoped-rules">
382- Scoped Style Rules</h4>
383-
384- <dfn>Scoped style rules</dfn> differ from non-scoped rules
385- in the following ways:
386-
387- * Their selectors can only match elements that are [=in scope=] .
388- (This only applies to the [=subject=] ;
389- the rest of the selector can match unrestricted.)
390-
391- * They accept a <<relative-selector-list>> as their prelude
392- (rather than just a <<selector-list>> ).
393- Such [=relative selectors=]
394- are relative to '':scope'' .
395-
396- * Any selector in the <<relative-selector-list>>
397- that does not start with a [=combinator=]
398- but does [=contain the nesting selector=] or the '':scope'' selector,
399- is interpreted as a non-[=relative selector=]
400- (but the [=subject=] must still be [=in scope=] to match).
401-
402- <h4 id="scope-limits">
403- Identifying Scoping Roots and Limits</h4>
404-
405- A ''@scope'' rule produces one or more [=scopes=] as follows:
406-
407- : Finding the [=scoping root=] (s)
408- :: For each element matched by <<scope-start>> ,
409- create a [=scope=] using that element as the [=scoping root=] .
410- If no <<scope-start>> is specified,
411- the [=scoping root=] is the [=parent element=] of the [=owner node=]
412- of the stylesheet where the ''@scope'' rule is defined.
413- (If no such element exists,
414- then the [=scoping root=] is the [=root=] of the containing [=node tree=] .)
415- Any '':scope'' or ''&'' selectors in <<scope-start>>
416- are interpreted as defined for its outer context.
417-
418- : Finding any [=scoping limits=]
419- :: For each [=scope=] created by a [=scoping root=] ,
420- its [=scoping limits=] are set to all elements
421- that are [=in scope=] and that match <<scope-end>> ,
422- interpreting '':scope'' and ''&''
423- exactly as in [=scoped style rules=] .
424-
425346 <div class=example>
426347 The following selectors have the same specificity (0,0,1):
427348
@@ -433,8 +354,11 @@ Identifying Scoping Roots and Limits</h4>
433354 :where(#hero) img { border-radius: 50%; }
434355 </pre>
435356
436- But because one <{img}> selector is scoped,
437- that selector is weighted more strongly in the cascade.
357+ The additional specificity of the ''#hero'' selector
358+ is not applied to the specificity of the scoped selector.
359+ However, since one <{img}> selector is scoped,
360+ that selector is weighted more strongly in the cascade
361+ with the application of [=weak scoping proximity=] .
438362 </div>
439363
440364 <div class=example>
@@ -523,6 +447,91 @@ Identifying Scoping Roots and Limits</h4>
523447 </pre>
524448 </div>
525449
450+ <h4 id="scope-syntax">
451+ Syntax of ''@scope''</h4>
452+
453+ The syntax of the ''@scope'' rule is:
454+
455+ <pre class="prod def">
456+ @scope [(<<scope-start>> )]? [to (<<scope-end>> )]? {
457+ <<stylesheet>>
458+ }
459+ </pre>
460+
461+ where:
462+
463+ * <dfn><<scope-start>></dfn> is a <<forgiving-selector-list>> [=selector=]
464+ used to identify the [=scoping root=] (s).
465+ * <dfn><<scope-end>></dfn> is a <<forgiving-selector-list>> [=selector=]
466+ used to identify any [=scoping limits=] .
467+ * the <<stylesheet>> represents the [=scoped style rules=] .
468+
469+ [=Pseudo-elements=] cannot be [=scoping roots=] or [=scoping limits=] ;
470+ they are invalid both within <<scope-start>> and <<scope-end>> .
471+
472+ <h4 id="scoped-rules">
473+ Scoped Style Rules</h4>
474+
475+ <dfn>Scoped style rules</dfn> differ from non-scoped rules
476+ in the following ways:
477+
478+ * Their selectors can only match elements that are [=in scope=] .
479+ (This only applies to the [=subject=] ;
480+ the rest of the selector can match unrestricted.)
481+
482+ * They accept a <<relative-selector-list>> as their prelude
483+ (rather than just a <<selector-list>> ).
484+ Such [=relative selectors=]
485+ are relative to '':scope'' .
486+
487+ * Any selector in the <<relative-selector-list>>
488+ that does not start with a [=combinator=]
489+ but does [=contain the nesting selector=] or the '':scope'' selector,
490+ is interpreted as a non-[=relative selector=]
491+ (but the [=subject=] must still be [=in scope=] to match).
492+
493+ <h4 id="scope-limits">
494+ Identifying Scoping Roots and Limits</h4>
495+
496+ A ''@scope'' rule produces one or more [=scopes=] as follows:
497+
498+ : Finding the [=scoping root=] (s)
499+ :: For each element matched by <<scope-start>> ,
500+ create a [=scope=] using that element as the [=scoping root=] .
501+ If no <<scope-start>> is specified,
502+ the [=scoping root=] is the [=parent element=] of the [=owner node=]
503+ of the stylesheet where the ''@scope'' rule is defined.
504+ (If no such element exists,
505+ then the [=scoping root=] is the [=root=] of the containing [=node tree=] .)
506+ Any '':scope'' or ''&'' selectors in <<scope-start>>
507+ are interpreted as defined for its outer context.
508+
509+ : Finding any [=scoping limits=]
510+ :: For each [=scope=] created by a [=scoping root=] ,
511+ its [=scoping limits=] are set to all elements
512+ that are [=in scope=] and that match <<scope-end>> ,
513+ interpreting '':scope'' and ''&''
514+ exactly as in [=scoped style rules=] .
515+
516+ <div class=example>
517+ [=Scoping limits=] can use the '':scope'' pseudo-class
518+ to require a specific relationship to the [=scoping root=] :
519+
520+ <pre class=lang-css>
521+ /* .content is only a limit when it is a direct child of the :scope */
522+ @scope (.media-object) to (:scope > .content) { ... }
523+ </pre>
524+
525+ [=Scoping limits=] can also reference elements outside their [=scoping root=]
526+ by using '':scope'' .
527+ For example:
528+
529+ <pre class=lang-css>
530+ /* .content is only a limit when the :scope is inside .sidebar */
531+ @scope (.media-object) to (.sidebar :scope .content) { ... }
532+ </pre>
533+ </div>
534+
526535<h4 id="scope-scope">
527536Scope Nesting</h4>
528537
0 commit comments