Re: [csswg-drafts] [css-nesting] & rules (#6119)

> & as described can produce two very different css rules depending on if the & is followed by `<whitespace><selector>` or just `<selector>`.

Yup, that's how Selectors normally work. ^_^ For example:

```css
.foo {
  ...
  &:hover { /* hover the .foo element */ }
  & :hover { /* hover a descendant of the .foo element */ }
}
```

This is identical to how `.foo:hover` and `.foo :hover` work.

>  Right now I'm not seeing any ambiguity in there

This is mentioned in passing in the intro to <https://drafts.csswg.org/css-nesting/#nesting> - selectors and properties are grammatically ambiguous with each other. For example, `color:red` and `div:hover` are both "two idents, separated by a colon"; you can't tell *for certain* which is which (at best, you can *guess*, based on your knowledge of CSS properties and HTML tagnames). This ambiguity can persist *indefinitely*, until you see a `;` or `{`; if you don't see either (because the parent rule closes with a `}`, for example), it might not be possible at all to tell which was intended.

------

Agreed that *concatenation* is an anti-feature, fwiw. It interacts very badly with other Selector features, so I explicitly rejected it early in Nesting's life.

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6119#issuecomment-803172339 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 19 March 2021 22:36:28 UTC