[csswg-drafts] [css-shadow-parts] match parts of the current shadow root (#7955)

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

== [css-shadow-parts] match parts of the current shadow root ==
**Background**: To match a shadow part from outside its own shadow root, we use the [`::part()`](https://w3c.github.io/csswg-drafts/css-shadow-parts/#part) pseudo-element selector.

```css
::part(day weekend) {
  color: blue;
}
```

That selector will have a [calculated specificity](https://drafts.csswg.org/selectors/#specificity-rules) of **1 Type**.

**Issue**: To match a shadow part from within its own shadow root, we use CSS attribute selector. It feels rather inelegant because of how dissimilar it is to the `::part()` selector.

```css
[part~="day"][part~="weekend"] {
  color: blue;
}
```

That selector will have a different calculated specificity; **2 Classes**. To match the `::part()` specificity of **1 Type**, we must add additional selector trickery.

```css
:where([part~="day"][part~="weekend"]):not(_) {
  color: blue;
}
```

That selector feels very long, cryptic, and too dissimilar from its light `::part()` counterpart.

**Recommendation**: May we add a `:host-part()` pseudo-class selector to match elements with the given parts?

```css
:host-part(day weekend) {
  color: blue;
}
```

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


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

Received on Wednesday, 26 October 2022 02:26:10 UTC