Skip to content

Commit 9a3b747

Browse files
argyleinkLeaVerou
andauthored
[css-nesting-1] Allow conditional nested rules to adopt context (#6483)
Co-authored-by: Lea Verou <lea@verou.me>
1 parent c31f4d9 commit 9a3b747

File tree

1 file changed

+19
-23
lines changed

1 file changed

+19
-23
lines changed

css-nesting-1/Overview.bs

+19-23
Original file line numberDiff line numberDiff line change
@@ -466,11 +466,12 @@ Nesting Conditional Rules {#conditionals}
466466
-----------------------------------------------
467467

468468
A style rule can have any number of <a>conditional rules</a> inside of it, of any type,
469-
intermixed with any number of declarations, in any order.
469+
with rules required to come after declarations (see <a href="#mixing">Mixing Nesting Rules and Declarations</a>).
470470

471-
The presence of a nested conditional engages the same logic as if ''@nest'' was present.
472-
The nested conditional rules must contain a <a>nesting selector</a> and follow the same
473-
rules as outlined in <a href="#direct">direct nesting</a>.
471+
If there are only declarations in the nested conditional, the nesting context is adopted.
472+
473+
In the presence of a <a>nesting selector</a>, the same
474+
rules as outlined in <a href="#direct">direct nesting</a> should be used.
474475

475476
<div class="example">
476477
For example, the following conditional nestings are valid:
@@ -480,14 +481,22 @@ Nesting Conditional Rules {#conditionals}
480481
display: grid;
481482

482483
@media (orientation: landscape) {
483-
& {
484-
grid-auto-flow: column;
485-
}
484+
grid-auto-flow: column;
486485
}
487486
}
488487
/* equivalent to
489488
.foo { display: grid; }
490489

490+
@media (orientation: landscape) {
491+
& {
492+
grid-auto-flow: column;
493+
}
494+
}
495+
*/
496+
497+
/* finally equivalent to
498+
.foo { display: grid; }
499+
491500
@media (orientation: landscape) {
492501
.foo {
493502
grid-auto-flow: column;
@@ -499,14 +508,10 @@ Nesting Conditional Rules {#conditionals}
499508
display: grid;
500509

501510
@media (orientation: landscape) {
502-
& {
503-
grid-auto-flow: column;
504-
}
511+
grid-auto-flow: column;
505512

506513
@media (min-inline-size > 1024px) {
507-
& {
508-
max-inline-size: 1024px;
509-
}
514+
max-inline-size: 1024px;
510515
}
511516
}
512517
}
@@ -551,15 +556,6 @@ Nesting Conditional Rules {#conditionals}
551556
But the following are invalid:
552557

553558
<pre class=lang-css>
554-
.foo {
555-
display: grid;
556-
557-
@media (orientation: landscape) {
558-
grid-auto-flow: column;
559-
}
560-
}
561-
/* Invalid because there's no nesting selector */
562-
563559
.foo {
564560
color: red;
565561

@@ -800,4 +796,4 @@ return the result of the following steps:
800796
</ol>
801797
<li>Append a newline followed by RIGHT CURLY BRACKET (U+007D) to |s|.
802798
<li>Return |s|.
803-
</ol>
799+
</ol>

0 commit comments

Comments
 (0)