Re: [csswg-drafts] [selectors-4] [css-nesting-1] pseudo elements need to be clarified to correctly handle relative selectors. (#7979)

Sass's behavior, and Chrome's, is correct. For historical reasons, while the `::` in `::before` is *similar to* a combinator, it's not exactly one; this is reflected in the grammar. (And we've finally properly built pseudo-elements into the grammar hierarchy now.) Thus `:has(::before)` or `.foo { ::before {...}}` are not ambiguous - the `::before` is read as having a descendant combinator before it, exactly the same as `:has(.bar)` and `.foo { .bar {...}}` would be. `.foo { &::before {...}}` is how you indicate you want the ::before pseudo on the parent rule's element, specifically. As Romain (and the spec) say, a bare `::before` is defined to be equivalent to `*::before`.

I wish pseudo-elements didn't have this sort of grammar, but we're stuck with it.

@Loirooriol The ":has-allowed pseudo-elements" concept we've carved out isn't for changing the meaning of something like `:has(::before)`. A future `:has(::foo)` that we define to be valid will still be equivalent to `:has(*::foo)`; there's currently no way to ask whether the subject element has a specific pseudo. We'd need the proposed `:>` combinator for that.

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


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

Received on Wednesday, 14 December 2022 15:54:06 UTC