Re: [csswg-drafts] [selectors] Child & descendant pseudo element combinators (#7346)

I hashed this out with Jake last week, and like this proposal; it addresses several of the pain points I've run into with pseudo-element syntax over the years.

Small detail, probably obvious from the examples: when selecting into the "pseudo tree" of an element, the pseudo-elements are treated as having *tagnames* equal to their names, so you use type selectors to target them. `div :> before` hits a `::before` pseudo, for example. This requires us to broaden the syntax of Selectors slightly to allow type selectors to also be functions, for things like `div :> slotted(.foo)`, but that shouldn't be problematic.

Also, in chained pseudo-elements like `::before::marker`, the `::marker` is part of the *pseudo tree" of the before, so you do have to write `* :> before :> marker`; `* :> before > marker` won't work, as the before pseudo-element doesn't have a `<marker>` child element. The pseudo-descendant combinator `:>>` just descends down the pseudo-children links, so `* |>> marker` grabs all markers, even those of pseudo-elements.

Jake's listed motivations are all great, and why I'd like this. In particular, it would allow us to finally revise the data model of pseudo-elements to *make some dang sense* when combined with other features like relative selectors and nesting, which makes me very happy. The `foo::bar` syntax will finally no longer be considered a weird compound selector; it's just a legacy way to write the complex selector `foo :> bar`, with a proper combinator and everything.

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


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

Received on Friday, 17 June 2022 21:43:14 UTC