4 ms·
I claim that an improved option 4 would be: parent { ...parent rules... } @nest { ...nested rules... } by analogy with `try { ... }
by sfink 4y ago
I claim that an improved option 4 would be:
parent {
...parent rules...
} @nest {
...nested rules...
}
by analogy with `try { ... } catch { ... }` syntax. Looks a lot better than the line noise `} {` thing.
An improved option 3 would be to unconditionally require the &.
Another alternative would be to stick with Sass syntax but require nested selectors to use :where:
parent {
...parent rules...
:where(child:pseudo) {
...nested rules...
}
}
and maybe allow :nest(...) as an alias of :where(...), except disallow it at the top level.
parent {
...parent rules...
:nest(child:pseudo) {
...nested rules...
}
}
Or play a similar weird trick to the original option 3 and only require :where(...)/:nest(...) for selectors that begin with a letter. But that starts to look a lot like option 3. Especially if you always require &, because then & can be used to disambiguate the child:pseudo parsing problem.
I'm not familiar with the past discussion of any of this, though.