[csswg-drafts] [css-values] attr() and part() / slotted() / element backed pseudo-elements behave inconsistently. (#12721)

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

== [css-values] attr() and part() / slotted() / element backed pseudo-elements behave inconsistently. ==
No change to the spec needed necessarily, but I find it somewhat weird that:

```css
my-element::part(foo) {
  width: attr(bar px);
}
```

Looks at the `bar` attribute on the part, rather than on `my-element`, where there wouldn't be a way for the outer tree to set the attribute value in any other way. In fact it allows leaking attributes out of the shadow tree sometimes at least via inheritance (if `foo` contains a `<slot>`).

Was that intentional? Implementation wise is definitely easier not to care about where the rule came from tho.

Maybe a note in the spec would be nice noting this oddity.

It gets a bit funnier for element-backed pseudo-elements tho, where should the attribute be looked at for those?

Per spec to the originating element, which seems fine, but it's a bit weird to have this divergence with `::part()`.

cc @tabatkins @lilles 

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


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

Received on Wednesday, 3 September 2025 10:13:29 UTC