4

Is it possible to select descendent element in slotted element?

Example like this:

::slotted(div p) {
        color: blue;
    }

<div><p>test</p><div>

It doesn't work

Intervalia
  • 10,248
  • 2
  • 30
  • 60
asv
  • 3,332
  • 7
  • 24
  • 47

1 Answers1

5

No, you can only select top-level nodes with ::slotted().

The selector inside ::slotted() can only be a compound selector, so div p is not a valid one.

According to Hayato Ito :

The reason of this restriction is to make a selector style-engine friendly, in terms of performance.

See the styling example in the Shadow Dom v1 presentation.

Supersharp
  • 29,002
  • 9
  • 92
  • 134