You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: css-nesting-1/proposals.md
+10-8Lines changed: 10 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ To organize the discussion a bit, the options we're looking at are:
9
9
1. Just at-rules. This means any nested at-rule, like a nested @media, or the no-op `@nest;` rule we'd introduce.
10
10
2. [(link)](https://github.com/w3c/csswg-drafts/issues/7834#issuecomment-1268979633) The above, plus any style rule starting with an `&`. (Rules following the switch can start with whatever.)
11
11
3. [(link)](https://github.com/w3c/csswg-drafts/issues/7834#issuecomment-1270665794) The above, plus any style rule starting with a non-ident. (So `.foo`, `:hover`, etc will trigger the switch, but `div` won't.) (Rules following the switch can start with whatever.)
12
-
3.[Lea's proposal](https://github.com/w3c/csswg-drafts/issues/7834#issuecomment-1272373216) - No parsing switch, instead every nested rule has to be unambiguous on its own, by starting with anything but an ident. (You can write `& div` or `:is(div)` if you need to start a selector with a type selector.) (This employs the same parsing strat as (2.3) to avoid accidentally parsing invalid properties like `//color: red;` as rules.)
12
+
3.[Lea's proposal](https://github.com/w3c/csswg-drafts/issues/7834#issuecomment-1272373216) - No parsing switch, instead every nested rule has to be unambiguous on its own, by starting with anything but an ident. (You can write `& div` or `:is(div)` if you need to start a selector with a type selector.) (This employs the same parsing strat as (2.iii) to avoid accidentally parsing invalid properties like `//color: red;` as rules.)
13
13
4.[Post-nesting proposal](https://github.com/w3c/csswg-drafts/issues/7834#issuecomment-1276360012) - Block after main rule containing nested rules, no `&` needed in nested selectors except for disambiguation
14
14
1. Could add the rule block with an `@nest` rule
15
15
2. Could add the rule block with special ASCII selector like bare `&` or `&&` to indicate association of nested rules with the previous selector
@@ -39,7 +39,7 @@ Arguments for each of the above options:
39
39
- More verbose than Sass/etc-style, which many authors are used to. (And is arguably just a good design.)
40
40
41
41
<tr>
42
-
<th>(2.1)
42
+
<th>(2.i)
43
43
<td>
44
44
45
45
- After the switch, syntax is the same as other nesting contexts.
@@ -52,25 +52,25 @@ Arguments for each of the above options:
52
52
- Can't mix properties and rules - all properties have to come first. (But this matches the data model anyway.)
53
53
54
54
<tr>
55
-
<th>(2.2)
55
+
<th>(2.ii)
56
56
<td>
57
57
58
-
- Same as (2.1), but you can avoid using `@nest;` most of the time if you instead start your first rule with `&`.
58
+
- Same as (2.i), but you can avoid using `@nest;` most of the time if you instead start your first rule with `&`.
59
59
60
60
61
61
<td>
62
62
63
63
- Need to pay somewhat more attention to context, and make sure your first rule is written correctly - either preceded by an at-rule, or starting with `&`.
64
64
65
65
<tr>
66
-
<th>(2.3)
66
+
<th>(2.iii)
67
67
<td>
68
68
69
-
- Same as (2.2), but you can avoid using `@nest;` in even more cases: unless your first selector starts with a type selector, you can just nest naively.
69
+
- Same as (2.ii), but you can avoid using `@nest;` in even more cases: unless your first selector starts with a type selector, you can just nest naively.
70
70
71
71
<td>
72
72
73
-
- Still somewhat context-sensitive, just less so than (2.2).
73
+
- Still somewhat context-sensitive, just less so than (2.ii).
74
74
- Prevents us from ever changing property syntax to start with an ascii glyph. (Like `+transform:...;` for additive properties?) (But these are probably already ruled out anyway, due to people using garbage to "comment out" their properties, like `//color: red;`, or `*color:red;` for an old IE hack.)
75
75
76
76
<tr>
@@ -86,7 +86,7 @@ Arguments for each of the above options:
86
86
<td>
87
87
88
88
- Rules are invalid if they start with a type selector, requiring them to be rephrased somehow. (Using `:is(div)`, starting with `&`, etc.)
89
-
- Like (2.3), prevents us from changing property syntax to start with an ascii glyph in the future. (But similarly, this is probably already lost to us.)
89
+
- Like (2.iii), prevents us from changing property syntax to start with an ascii glyph in the future. (But similarly, this is probably already lost to us.)
90
90
91
91
<tr>
92
92
<th>(4)
@@ -96,6 +96,7 @@ Arguments for each of the above options:
96
96
- No double-nested indentation
97
97
- No `&` for selectors that do not require it
98
98
- Full compatibility with `@scope` and root contexts
99
+
- No `@nest` in variants (4.ii) and (4.iii)
99
100
100
101
<td>
101
102
@@ -104,5 +105,6 @@ Arguments for each of the above options:
104
105
- Requires either noisy `@nest` everywhere or cryptic ASCII syntax
105
106
- CSSOM with (arguably) a different structure than the syntax
106
107
- Can't mix properties and rules - all properties have to come first. (But this matches the data model anyway.)
108
+
- If you are *only* nesting rules, you still need an empty declaration block (`{}`), which looks awkward
0 commit comments