Re: [csswg-drafts] [css-nesting] selecting grandparent selector with @nest (#6977)

First, I have to say I keep stumbling on use cases for this. Things like:

```css
.container {
 & .widget {
  @nest .container.selected & {
   /* FAIL, gets rewritten to .container.selected .container .widget, 
      not .container.selected .widget */
  }
 } 
}
```

Also, I agree my proposal in https://github.com/w3c/csswg-drafts/issues/6330#issuecomment-851615137 is overkill. Also, it introduces a CSS property that is not actually applied on any elements, but is just used to evaluate syntax. Yikes.

Instead, I think we should go for a simpler solution, with predefined names for going up 1, 2, 3, ... levels. Perhaps `&1`, `&2`, `&3` etc. Then the example above would become:

```css
.container {
 & .widget {
  @nest &1.selected & {
   /* Gets rewritten to .container.selected .widget */
  }
 } 
}
```

Is `&1` cryptic? Yes. But it isn't more cryptic than `&` itself, and it kinda reminds me of `$1`, `$2` etc in JS string replacement.

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


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

Received on Sunday, 23 January 2022 11:20:11 UTC