Skip to content

Commit

Permalink
[@scope] Allow declarations directly within @scope (#11161)
Browse files Browse the repository at this point in the history
  • Loading branch information
andruud authored Nov 8, 2024
1 parent 41b102f commit 0fff97f
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions css-cascade-6/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ Syntax of ''@scope''</h4>

<pre class="prod def">
@scope [(<<scope-start>>)]? [to (<<scope-end>>)]? {
<<rule-list>>
<<block-contents>>
}
</pre>

Expand All @@ -448,7 +448,10 @@ Syntax of ''@scope''</h4>
used to identify the [=scoping root=](s).
* <dfn><<scope-end>></dfn> is a <<selector-list>> [=selector=]
used to identify any [=scoping limits=].
* the <<rule-list>> represents the [=scoped style rules=].
* the [=qualified rules=] within <<block-contents>>,
as well as any [=nested declarations rules=]
produced by [[#scoped-declarations|scoped declarations]],
represents the [=scoped style rules=].

[=Pseudo-elements=] cannot be [=scoping roots=] or [=scoping limits=];
they are invalid both within <<scope-start>> and <<scope-end>>.
Expand Down Expand Up @@ -667,6 +670,39 @@ Issue(10795): Should the scope proximity calculation be impacted by nesting scop
(e.g. within ''@layer'')
are [=scoped style rules|scoped=].

<h4 id="scoped-declarations">
Scoped Declarations </h4>

[=Declarations=] may be used directly
with the body of a ''@scope'' rule.
Contiguous runs of [=declarations=]
are wrapped in [=nested declarations rules=],
which match the [=scoping root=]
with zero [=specificity=].

<div class=example>
<pre highlight=css>
@scope (.foo) {
border: 1px solid black;
}
</pre>

is equivalent to:

<pre highlight=css>
@scope (.foo) {
:where(:scope) {
border: 1px solid black;
}
}
</pre>
</div>

Just like for [=style rules=],
[=declarations=] and child [=rules=]
may be [[css-nesting-1#mixing|mixed]]
within ''@scope''.

<h3 id="preshint">
Precedence of Non-CSS Presentational Hints</h3>

Expand Down Expand Up @@ -734,6 +770,9 @@ Changes since the 21 March 2023 Working Draft</h3>
Significant changes since the
<a href="https://www.w3.org/TR/2023/WD-css-cascade-6-20230321/">21 March 2023 Working Draft</a> include:

* Allowed [=declarations=] directly within ''@scope''.
(<a href="https://github.com/w3c/csswg-drafts/issues/10389">Issue 10389</a>)

* The '':scope'' selector can match the [=featureless=] [=shadow host=] when
that host is the [=scoping root=] element.
(<a href="https://github.com/w3c/csswg-drafts/issues/9025">Issue 9025</a>)
Expand Down

0 comments on commit 0fff97f

Please sign in to comment.