[csswg-drafts] [selectors-4] Should *all* functional pseudo-classes pass restrictions to selector arguments? (#12718)

cdoublev has just created a new issue for https://github.com/w3c/csswg-drafts:

== [selectors-4] Should *all* functional pseudo-classes pass restrictions to selector arguments? ==
If I am not mistaken, [`:has()`](https://drafts.csswg.org/selectors-4/#relational), [`:nth-*-child()`](https://drafts.csswg.org/selectors-4/#the-nth-child-pseudo), `:current()`, `host-*()`, are the only functional pseudo-classes taking a selector as their arguments, that are not logical pseudo-classes.

I suspect they should *pass any restrictions on validity of selectors at their position to their arguments*, like logical pseudo-classes. Otherwise, these cases would be valid:

  - `::slotted(:has(type))` (valid in FF)
  - `::slotted(:nth-child(1 of :hover > :hover))` (valid in Chrome)
  - `:host(:has(type))` (valid in FF)
  - `:host(:nth-child(1 of :hover > :hover))` (valid in Chrome)

This is surprising because the following cases are invalid per spec and in Chrome/FF:

  - `::slotted(* > type)`
  - `::slotted(:hover > :hover:nth-child(1))`
  - `:host(type > type)`
  - `:host(:hover > :hover:nth-child(1))`

`::slotted()` and `:host-*()` take compound selectors, but `has()` takes relative selectors and `:nth-*-child()` takes complex selectors.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/12718 using your GitHub account


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

Received on Tuesday, 2 September 2025 14:30:58 UTC