first reported here : https://github.com/csstools/postcss-plugins/issues/510 relevant specification parts: https://www.w3.org/TR/css-nesting-1/#nest-selector >The [nesting selector](https://www.w3.org/TR/css-nesting-1/#nesting-selector) can be desugared by replacing it with the parent style rule’s selector, wrapped in an [:is()](https://www.w3.org/TR/selectors-4/#matches-pseudo) selector. For example, https://www.w3.org/TR/selectors-4/#matches-pseudo >Pseudo-elements cannot be represented by the matches-any pseudo-class; they are not valid within [:is()](https://www.w3.org/TR/selectors-4/#matches-pseudo). For this CSS : ```pcss .anything::before { @nest .something_else > & { color: black } } ``` `&` should represent the matched element of the enclosing rule. Which in this case is `before`. This CSS : 1. is invalid 2. is valid but never matches 3. matches `.something_else > .anything::before` 4. matches `.something_else.anything::before` (or `.something_else.anything :> before`) Also relevant : - https://github.com/w3c/csswg-drafts/issues/2284#issuecomment-364580632 - https://github.com/w3c/csswg-drafts/issues/7346#issue-1266265523
first reported here : csstools/postcss-plugins#510
relevant specification parts:
https://www.w3.org/TR/css-nesting-1/#nest-selector
https://www.w3.org/TR/selectors-4/#matches-pseudo
For this CSS :
&should represent the matched element of the enclosing rule.Which in this case is
before.This CSS :
.something_else > .anything::before.something_else.anything::before(or.something_else.anything :> before)Also relevant :
:is()/:matches()? #2284 (comment)