Re: [csswg-drafts] [css-scoping-1][css-shadow-parts-1] Clarify which selectors can come after `::slotted()` and `::part()` (#8517)

Actually, I should not have edited my original comment to omit `:host-*` because all corresponding cases in the table below seem to select nothing in Chrome (C) and Firefox (FF), even if they are parsed as valid:

| Selector                 | C  | FF
| ------------------------ | -- | --
| `:host:hover`            | ✔️ | ✔️
| `:host:not(r > t)`       | ✔️ | ✔️
| `:host:is(s > t)`        | ✔️ | ✔️
| `:host:has(c)`           | ✔️ | ❌
| `:host:first-child`      | ✔️ | ✔️
| `::slotted(t):hover`     | ❌ | ❌
| `::slotted(t):not(u)`    | ❌ | ❌
| `::slotted(t):is(t)`     | ❌ | ✔️
| `::slotted(t):is(s > t)` | ❌ | ✔️
| `::part(p):hover`        | ✔️ | ✔️
| `::part(p):not(u)`       | ✔️ | ❌
| `::part(p):not(r > t)`   | ✔️ | ❌
| `::part(p):is(s > t)`    | ✔️ | ✔️

According to [3.6.3. Pseudo-classing Pseudo-elements](https://drafts.csswg.org/selectors-4/#pseudo-element-states), user actions and logical combinations (`:is()`, `:not()`, `:where()`) are supposed to be always valid after a pseudo-element. However:

  - I am not sure when a logical combination compounded to `::part()` is *based on tree information* (when it includes complex selectors?) and should match nothing, but all corresponding cases in the table seem to select the matching elements in Chrome and FF
  - `::slotted()` is supposed to pass its restrictions (tree-abiding pseudo-elements) to logical combination pseudo-classes, but that does not make sense here because it represents elements, and because pseudo-elements are invalid in logical combinations (eg. `::slotted(*):not(::before)`)
  
I think both should restrict logical combinations to `<compound-selector>`.

In hindsight, I think I would rather let a selector match nothing, because validation during parsing can be non-trivial, and because invalid selectors can make the whole rule invalid.

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


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

Received on Wednesday, 8 March 2023 12:42:24 UTC