Open devknoll opened 2 years ago
If I had to guess, it was done this way because technically you are selecting a slot
element with the ::slotted
pseudo element. The slot
belongs to the tree with the style, but the slotted content doesn't. I guess this makes sense.
Still sort of confusing though 😄
Some prior discussion and rationale here: https://github.com/whatwg/dom/issues/463
I'm having trouble finding prior discussion and I'm a noob and not a spec person, so apologies in advance.
::slotted(...)
selects real elements within the same shadow tree as the selector, so it's unclear to me why it should be a pseudo element while e.g.:has(...)
/:where(...)
/:is(...)
/:host(...)
/:host-context(...)
are all pseudo classes. One real world issue with this is that I can'tquerySelectorAll
inside a shadow DOM for a::slotted()
selector, despite the selector targeting real elements by definition.In contrast,
::part(...)
being a pseudo element makes sense, since the element is essentially abstract from the point of view of the selector, since the actual element belongs to a different (shadow) tree.There's probably some underlying reason here that I'm missing (and I would very much appreciate learning something new!) but otherwise this seems like it could be a nice low hanging improvement.