-
Notifications
You must be signed in to change notification settings - Fork 756
Description
https://drafts.csswg.org/css-nesting/#at-nest
The @nest rule functions identically to a style rule: it starts with a selector, and contains declarations that apply to the elements the selector matches. The only difference is that the selector used in a @nest rule must be nest-containing, which means it contains a nesting selector in it somewhere. A list of selectors is nest-containing if all of its individual complex selectors are nest-containing.
Since there is no ambiguity with @nest, neither syntactic, nor ambiguity of intent, why still force &? We can just default to the descendant selector, just like preprocessors.
This, is a little awkward:
.foo {
@nest & .bar {
color: white;
}
}compared to:
.foo {
@nest .bar {
color: white;
}
}Yes, in that case you don't actually need @nest, but some people may prefer it for the explicitness, or it could be generated. In any case, it's a sensible default, that is trivial to implement, and has already been tested for both utility and usability in preprocessors.