Skip to content

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

@emilio

Description

@emilio

No change to the spec needed necessarily, but I find it somewhat weird that:

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions