- From: Guillaume via GitHub <sysbot+gh@w3.org>
- Date: Thu, 02 Mar 2023 15:28:44 +0000
- To: public-css-archive@w3.org
cdoublev has just created a new issue for https://github.com/w3c/csswg-drafts: == [css-scoping-1][css-shadow-parts-1] Clarify which selectors can come after `:host-*`, `::slotted()`, `::part()` == If I understand correctly, basically, these selectors pierce the associated shadow DOM but it should not be possible to read more from the destination DOM (light or shadow) than the selected element. [`::slotted()`](https://drafts.csswg.org/css-scoping-1/#selectordef-slotted) and [`::part()`](https://drafts.csswg.org/css-shadow-parts-1/#selectordef-part) have different restrictions on the pseudo-classes and pseudo-elements that can be compounded: > The `::slotted()` pseudo-element can be followed by a tree-abiding pseudo-element, like `::slotted()::before`, representing the appropriate pseudo-element of the elements represented by the `::slotted()` pseudo-element. > The `::part()` pseudo-element can take additional pseudo-classes after it, such as `x-button::part(label):hover`, but never matches the structural pseudo-classes or any other pseudo-classes that match based on tree information rather than local element information. > > The `::part()` pseudo-element can also take additional pseudo-elements after it, such as `x-button::part(label)::before`, but never match additional `::part()`s. According to *3.6.5. Internal Structure* [(Selectors 4)](https://drafts.csswg.org/selectors-4/#pseudo-element-structure), `::slotted()` and `::part()` cannot be combined with another selector: > Some pseudo-elements are defined to have internal structure. These pseudo-elements may be followed by child/descendant combinators to express those relationships. Selectors containing combinators after the pseudo-element are otherwise invalid. Note: explaining this restriction with this definition seems a bit of a stretch because `::slotted()` and `::part()` represent elements, not pseudo-elements. As for [`:host-*`](https://drafts.csswg.org/css-scoping-1/#host-selector) (`:host`, `:host()`, `:host-context()`), it currently has no restriction. I am not sure why a selector should be invalid rather than match nothing, nor if consistency between these selectors is actually required, but can you please confirm me that restrictions on `:host-*` and `::slotted()` are theoretically supposed to be similar as for the pseudo-classes compounded with `::part()`, something like *the selector can take any pseudo-class or pseudo-selector that require tree information rather than local element information*? Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8517 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Thursday, 2 March 2023 15:28:45 UTC