- From: Lea Verou via GitHub <sysbot+gh@w3.org>
- Date: Thu, 27 Oct 2022 17:51:27 +0000
- To: public-css-archive@w3.org
> I'm trying to get a handle on proposal 3, more specifically this idea of implicit & insertion (which I really think is a bad idea, but people seem to feel very strongly about it). Could we formulate clearly when & is inserted and when it's not, in a way that doesn't require lookahead to specify what is a valid rule? For instance: Not an editor of Nesting, but since option 3 was [my proposal](https://github.com/w3c/csswg-drafts/issues/7834#issuecomment-1272373216), I'll make an attempt to answer some of these. > * `.foo { .bar { … }}` — seemingly this should be interpreted as `& .bar` Yes, it would be `& .bar`, with `&.bar` requiring the `&`, just like Sass. > * `.foo { .bar & { … }}` — this should _not_ be interpreted as `& .bar &`, because there's already a & in there (it's nest-containing)? Correct. > * `.foo { > .bar & { … }}` — however, this should be interpreted as `& > .bar &`, because it starts with a combinator? Or should this be a parse error? (Why?) That would be `& > .bar &`, yes. > * `.foo { :hover { … }}` — This should be `& :hover` and _not_ `&:hover`? But I've seen examples where people seem to assume it's the latter. Yes. Again, it's descendant by default, just like preprocessors. For `&:hover` the `&` is mandatory. > * `.foo { :is(&) { … }}` — Should this be interpreted as `& :is(&)` or just `:is(&)`? I would assume the latter, since it's nest-containing, but you may have to dig pretty deep to find the &. Yes, it's `:is(&)`, not `& :is(&)`. Digging deep to find the `&` is fine, what we're trying to avoid is having to dig deep to find whether it's a rule or a declaration. > * `.foo { :is(.bar, !#&/) { … }}` — Is this nest-containing (which then decides whether there should be a `& ` in front? There's an & in there, but it's dropped in forgiving selector parsing. I'd file a new issue for this. > > And finally: > > * `.foo { .bar { … }}` — how do we serialize this? > * `.foo { & .bar { … }}` — how do we serialize this? > * `.foo { > .bar { … }}` — how do we serialize this? > * `.foo { & > .bar { … }}` — how do we serialize this? I suppose it's fine to serialize with the implicit `&`. > * `.foo { .bar &, .baz { … } }` — I assume this should be interpreted as `.bar &, & .baz`? Yes. > * `.foo { :is(.bar &, .baz) { … } }` — but this should be interpreted as `:is(.bar &, .baz)`, so not consistent with the previous one? I'd file a separate issue for that one too. > * `.foo { > .bar, .baz { … } }` — and this should be `& > .bar, & .baz`? Yes. > * `.foo { > .bar, + .baz { … } }` — and this should be `& > .bar, & + .baz`? Yes. -- GitHub Notification of comment by LeaVerou Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7834#issuecomment-1293871991 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Thursday, 27 October 2022 17:51:29 UTC