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

> there's no definite originating element for a given part

Right, but that's because it's actually a ["real element"](https://drafts.csswg.org/css-pseudo-4/#element-like:~:text=An%20element%2Dbacked%20pseudo%2Delement%20can%20define%20itself%20as%20representing%20a%20real%20element). Isn't it weird for a pseudo-element selector reaching a _real element_ to _not_ be element-backed?

You're right that `::part()` is not explicitly specified as such in css-shadow-parts ... but css-pseudo-4 sure seems to think so:

https://drafts.csswg.org/css-pseudo-4/#element-like

> All [pseudo-classes](https://www.w3.org/TR/CSS2/selector.html#x23) and [pseudo-elements](https://www.w3.org/TR/CSS2/selector.html#x22) are syntactically allowed after an **[element-backed pseudo-element]**(https://drafts.csswg.org/css-pseudo-4/#element-backed) (**such as x-button::part(label):hover or x-button::part(label)::before**), just as if the pseudo-element were a [type selector](https://drafts.csswg.org/selectors-4/#type-selector); but some are disallowed from matching: [...]

> [::part()](https://drafts.csswg.org/css-shadow-parts-1/#selectordef-part) never matches. (**Other [element-backed pseudo-elements](https://drafts.csswg.org/css-pseudo-4/#element-backed) can**, however.)

Anyway, assuming that `::part()` _is_ intended to be element-backed, we could follow the lead from sibling-index():

> When used on an [element-backed pseudo-element](https://drafts.csswg.org/css-pseudo-4/#element-backed) which is also a real element, the tree counting functions resolve for that real element.

=>

```
When used on an element-backed pseudo-element
which is also a real element,
`attr()` resolves against the attributes of that real element.
```


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


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

Received on Friday, 5 September 2025 07:57:12 UTC