Skip to content

Commit 41ccdee

Browse files
committed
[css-nesting-1] Clarify what it means to 'contain a nesting selector', and the CSSWG resolution to preserve forgiving selectors that are invalid but contain the nesting selector. #7972
1 parent e6148b9 commit 41ccdee

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

css-nesting-1/Overview.bs

+29-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ Introduction</h2>
3434
Module Interactions</h3>
3535

3636
This module introduces new parser rules that extend the [[!CSS21]] parser model.
37-
This module introduces selectors that extend the [[SELECTORS4]] module.
37+
It introduces selectors that extend the [[SELECTORS-4]] module.
38+
It extends and modifies some IDL and algorithms defined in the [[CSSOM-1]] module.
3839

3940
<h3 id="values">
4041
Values</h3>
@@ -268,7 +269,7 @@ Syntax {#syntax}
268269
are relative to the elements represented by the [=nesting selector=].
269270
* If a selector in the <<relative-selector-list>>
270271
does not start with a [=combinator=]
271-
but does contain the [=nesting selector=],
272+
but does [=contain the nesting selector=],
272273
it is interpreted as a non-[=relative selector=].
273274

274275
The precise details of how nested style rules are parsed
@@ -570,6 +571,31 @@ Syntax {#syntax}
570571
</pre>
571572
</div>
572573

574+
<div algorithm>
575+
A selector is said to <dfn export>contain the nesting selector</dfn>
576+
if, when it was [=CSS/parsed=] as any type of selector,
577+
a <<delim-token>> with the value "&" (U+0026 AMPERSAND) was encountered.
578+
579+
Note: This is phrased in this explicit manner
580+
so as to catch cases like '':is(&:unknown, .bar)'',
581+
which discards its first argument during parsing
582+
(since it contains an unknown pseudo-class,
583+
and thus is an [=invalid selector=]).
584+
A selector like this still [=contains the nesting selector=].
585+
</div>
586+
587+
If a <<forgiving-selector-list>> has an item that [=contains the nesting selector=]
588+
but is invalid,
589+
it is preserved exactly as-is
590+
rather than being discarded.
591+
(This does not change the matching behavior of the selector--
592+
an invalid selector still fails to match anything--
593+
just the serialization of the selector.)
594+
595+
Issue: The preceding paragraph needs to move to Selectors
596+
when we move ''&'' itself to Selectors;
597+
I'm monkey-patching for convenience here.
598+
573599

574600

575601
<!--
@@ -1171,4 +1197,4 @@ that starts with an ident or function token,
11711197
do nothing and return.
11721198

11731199
Issue: The above paragraph will be inlined into the CSSOM algo,
1174-
rather than monkey-patched.
1200+
rather than monkey-patched.

0 commit comments

Comments
 (0)