Re: :host pseudo-class

On Mon, Apr 27, 2015 at 9:03 AM, Rune Lillesveen <rune@opera.com> wrote:
> On Mon, Apr 27, 2015 at 6:22 AM, Anne van Kesteren <annevk@annevk.nl> wrote:
>> Would they match against elements in the host's tree or the shadow
>> tree? I don't see anything in the specification about this.
>
> They would match elements in the shadow tree.
>
> A typical use case is to style elements in the shadow tree based on
> its host's attributes:
>
> <my-custom-element disabled>
>     <custom-child></custom-child>
> </my-custom-element>
>
> In the shadow tree for <my-custom-element>:
>
> <style>
>     :host([disabled]) ::content custom-child { color: #444 }
>     :host([disabled]) input { border-color: #ccc }
> </style>
> <content></content>
> <input type=text>

Thanks, that example has another confusing bit, ::content. As far as I
can tell ::content is not actually an element that ends up in the
tree. It would make more sense for that to be a named-combinator of
sorts. (And given ::content allowing selectors on the right hand, it's
now yet more unclear why :host is not ::host.)


-- 
https://annevankesteren.nl/

Received on Monday, 27 April 2015 08:06:35 UTC