Re: [csswg-drafts] [css-nesting] referencing an ancestor selector (#3747)

> I believe your "main use case for wanting to do this is when a parent has a hover/focus state that affects the styling of a nested child element" is covered in the current draft like so?

The example you gave is too simplified.

This request makes the most sense when you are using BEM.

The use case is that an element of a block has a hover state. A child element inside the hover element needs styling based on the hover state. Doing this without BEM doesn't reveal the issue.

If you use the current spec as is, you get this which is incorrect.

```scss
.foo {
  &__bar {
    &:hover {
      &__baz {
        // .foo__bar:hover__baz { ... }
      }
    }
  }
}
```
That produces this rule:
```
.foo__bar:hover__baz { ... }
```
What I'd like is this:
```
.foo__bar:hover .foo__baz { ... }
```
I'd like a way to reference and reuse an ancestor selector deeper in the nest without having to repeat it.

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

Received on Tuesday, 19 March 2019 23:11:43 UTC