W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2015

Re: :host pseudo-class

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Tue, 5 May 2015 11:39:55 -0700
Message-ID: <CAAWBYDBZytrBZQCyjFaWapTHxEbH0eTfmX9ot1C82wYNc_OtDw@mail.gmail.com>
To: Anne van Kesteren <annevk@annevk.nl>
Cc: Elliott Sprehn <esprehn@chromium.org>, "www-style@w3.org" <www-style@w3.org>, "L. David Baron" <dbaron@dbaron.org>, WebApps WG <public-webapps@w3.org>
On Mon, May 4, 2015 at 9:38 PM, Anne van Kesteren <annevk@annevk.nl> wrote:
> On Tue, May 5, 2015 at 2:08 AM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
>> On Thu, Apr 30, 2015 at 10:51 PM, Anne van Kesteren <annevk@annevk.nl> wrote:
>>> But maybe you're right and the whole
>>> pseudo-class/pseudo-element distinction is rather meaningless. But at
>>> least pseudo-class til date made some sense.
>>
>> I still don't understand what you find wrong with this.  It's not that
>> ":host() [can] match an element that cannot otherwise be matched",
>> it's that the host element element is featureless, save for the
>> ability to match :host.  (That's the definition of a featureless
>> element - it's allowed to specify particular things that can still
>> match it.)  In other words, it's not :host that's magical, it's the
>> host element itself that's magical.
>
> So :host:hover would not work? I guess you would have to spell that
> :host(:hover)? Because although it does not have features, it has
> features inside the parenthesis?

Correct. The functional :host() pseudo-class can match the selector
against the *real* host element that hosts the shadow tree (and
:host-context() can do so for the entire shadow-piercing ancestor
tree).  But normal selectors inside a shadow tree only see the
featureless version of the host element that lives inside of the
shadow tree.

> Was this concept introduced for other scenarios or just for :host?
> Seems like a very weird rationalization.

Yeah, it was introduced to give the host element the selection
behavior we wanted (I explained this in more detail in my first post
in the thread).

It's certainly no weirder, imo, than having a pseudo-element that
doesn't actually live in any element's pseudo-tree, but instead just
lives in the normal DOM, but can only be selected by using a
pseudo-element selector with no LHS.  Pseudo-elements are fucked,
unfortunately, but we have to live with their quirks, and those quirks
make them really bad for this particular case.

~TJ
Received on Tuesday, 5 May 2015 18:40:44 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:27:31 UTC