Re: [csswg-drafts] [css-cascade] [css-nesting] Figure out whether we're fine with "shifting up" bare declarations after rules (#8738)

Thinking a bit about all of this: I think it could be actually safe enough to shift things? Basically, only cases that could break are when the nested selector is just `&` or `&:where(…)`, otherwise the specificity will be different anyway, and regardless of if we shift the declarations or not, the styles will be applied in the same order. I don't know if the counters did account for this.

Basically, there is no difference if we have 

```CSS
.foo {
    display: block;    

    &.is-hidden {
        display: none;
    }
}
```

and

```CSS
.foo {
    &.is-hidden {
        display: none;
    }
   display: block;
 }
```

regardless of where the declarations will be moved. The only difference is for something like

```CSS
.foo {
    & {
        display: none;
    }
   display: block;
 }
```

or

```CSS
.foo {
    &:where(.something) {
        display: none;
    }
   display: block;
 }
```

where there is no difference in specificity, so the order is what matters.

Also, another big difference that plays into that, and where things are already different than with preprocessors: given how native nesting wraps everything with `:is()`, something more practical like `&, &.something {}` will be different for native CSS and preprocessors already, with the native CSS this having the specificity of the highest selector, thus not having a difference in the placement.

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


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

Received on Wednesday, 10 April 2024 13:56:31 UTC