Skip to content

[scoping] Selectors in ::slotted don’t affect specificity #2271

@surma

Description

@surma

Let’s say I have a custom element <my-elem>, that has the following shadow root markup:

<style>
  /* ... */
  ::slotted(main) {
    background-color: blue;
  }
  ::slotted(*) {
    background-color: red;
  }
</style>
<slot></slot>
<my-elem>
  <div>DIV!</div>
  <main>MAIN!</main>
  <aside>ASIDE!</aside>
</my-elem>

I’d argue most authors would expect <main> to have a blue background color, but it is in fact red. AFACIT, this is currently per spec. Selectors passed to ::slotted() don’t affect specificity. So precedence is defined by order of declaration.

Was this intentional? If so, why? If not, is it changeable?

(Live demo, code)

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