Skip to content

Commit 5dc8ae1

Browse files
committed
[css-cascade-6] Lower boundary scope limit selectors are excluded from scope #6577
1 parent c24914b commit 5dc8ae1

File tree

1 file changed

+42
-14
lines changed

1 file changed

+42
-14
lines changed

css-cascade-6/Overview.bs

+42-14
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ Cascade Layers</h3>
212212

213213
Issue: [[css-cascade-5#layering]]
214214

215+
<h4 id="layer-ordering">
216+
Layer Ordering</h4>
217+
218+
Issue: [[css-cascade-5#layer-ordering]]
219+
215220

216221
<!--
217222
██████ ██████ ███████ ████████ ████ ██ ██ ██████
@@ -239,13 +244,12 @@ Scoped Styles</h2>
239244
Each element matched by <<scope-end>> is a [=scoping limit=].
240245
The <dfn>scoping limit</dfn> elements define the lower bounds of a scope,
241246
so that [=scoped selectors=] are not able to match
242-
any elements nested within them.
247+
any [=scoping limit=] elements,
248+
or any elements nested within them.
243249

244250
Each resulting [=scope=] includes a [=scoping root=] and all its descendants,
245-
up to and including any [=scoping limit=] elements,
246-
but not the descendants of those limits.
247-
248-
Issue(6577): Inclusive vs exclusive scope boundaries
251+
up to any [=scoping limit=] elements. [=Scoping limit=] elements and
252+
their descendants are not included in the [=scope=].
249253

250254
Note: In contrast to [[CSS-SCOPING-1#shadow-dom|Shadow Encapsulation]],
251255
which describes a persistent one-to-one relationship in the DOM
@@ -280,17 +284,16 @@ Scoped Styles</h2>
280284
For example:
281285

282286
<pre class=lang-css>
283-
@scope (.media-object) to (.content) {
287+
@scope (.media-object) to (.content > *) {
284288
img { border-radius: 50%; }
285-
286-
/* it is also possible to style the lower limit element itself */
287289
.content { padding: 1em; }
288290
}
289291
</pre>
290292

291293
The ''img'' selector will only match image tags that are in a DOM fragment
292294
starting with any ''.media-object'',
293-
and including all descendants until any intervening ''.content'' class.
295+
and including all descendants up to
296+
any intervening children of the ''.content'' class.
294297
</div>
295298

296299
Issue: Should scoping limits be added to the definition of [=scoped selectors=]?
@@ -425,31 +428,45 @@ Scoping Styles: the ''@scope'' rule</h4>
425428
&lt;section data-scope="main-component">
426429
&lt;p>...&lt;p>
427430
&lt;section data-scope="sub-component">
428-
&lt;!-- children are only in the inner scope -->
429431
&lt;p>...&lt;p>
430432
&lt;/section>
431433
&lt;/section>
432434
</pre>
433435

434436
Then the class or attribute can be used
435-
for establishing both upper and lower boundaries,
436-
such that scopes only overlap at those boundaries:
437+
for establishing both upper and lower boundaries.
438+
Elements matched by a lower boundary selector
439+
are excluded from the resulting scope,
440+
which allows authors to create non-overlapping scopes by default:
437441

438442
<pre class=lang-css>
439443
@scope ([data-scope='main-component']) to ([data-scope]) {
440444
p { color: red; }
441445

442-
/* both sections are part of the outer scope */
446+
/* only the outer section is part of the outer scope */
443447
section { background: snow; }
444448
}
445449

446450
@scope ([data-scope='sub-component']) to ([data-scope]) {
447451
p { color: blue; }
448452

449-
/* the inner section is also part of the inner scope */
453+
/* the inner section is only part of the inner scope */
450454
section { color: ghostwhite; }
451455
}
452456
</pre>
457+
458+
However, authors can use the child combinator
459+
and universal selector to create scope boundaries that overlap,
460+
such that the inner scope root is part of both scopes:
461+
462+
<pre class=lang-css>
463+
@scope ([data-scope='main-component']) to ([data-scope] > *) {
464+
p { color: red; }
465+
466+
/* both sections are part of the outer scope */
467+
section { background: snow; }
468+
}
469+
</pre>
453470
</div>
454471

455472
''@scope'' rules can be nested.
@@ -597,6 +614,17 @@ Precedence of Non-CSS Presentational Hints</h3>
597614
<h2 id="changes">
598615
Changes</h2>
599616

617+
This appendix is <em>informative</em>.
618+
619+
<h3 id="changes-2022-08">
620+
Changes since the 21 December 2021 First Public Working Draft</h3>
621+
622+
Significant changes since the
623+
<a href="https://www.w3.org/TR/2021/WD-css-cascade-6-20211221/">21 December 2021 First Public Working Draft</a> include:
624+
625+
* [=Scoping limit=] elements are excluded from the resulting [=scope=].
626+
(<a href="https://github.com/w3c/csswg-drafts/issues/6577">Issue 6577</a>)
627+
600628
<h3 id="additions-l5">
601629
Additions Since Level 5</h3>
602630

0 commit comments

Comments
 (0)