W3C home > Mailing lists > Public > www-style@w3.org > March 2015

Re: [css-scoping] context for evaluating selectors

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Wed, 25 Mar 2015 14:45:25 -0700
Message-ID: <CAAWBYDC_pC96LUn63DfCWektcmQNWACSs+GvQiWptaOS+BmJzQ@mail.gmail.com>
To: "L. David Baron" <dbaron@dbaron.org>
Cc: www-style list <www-style@w3.org>
On Mon, Mar 23, 2015 at 6:28 PM, L. David Baron <dbaron@dbaron.org> wrote:
> The definitions of the :host, :host(), and :host-context() pseudo
> classes in http://drafts.csswg.org/css-scoping/#host-selector all
> refer to the selectors being "evaluated in the context of a shadow
> tree".
>
> However, I don't see a definition of what this means.
>
> Tab and I discussed this briefly on IRC last week:
> http://logs.csswg.org/irc.w3.org/css/2015-03-16/#e533427
> where Tab gave the following rough definition:
>   <TabAtkins> Not well! I wasn't sure what the right hooks were. But
>   it should be "from a <style> or <link> inside a shadow tree, or in
>   a DOM api (somehow) rooted in a shadow tree".
>   ...
>   <TabAtkins> I think that if you can start the selector in a shadow
>   tree or on a shadow root, you're "in the context"

More concretely, the right answer is "within a stylesheet attached to
a shadow tree" (plus the DOM API thing - shadowTree.querySelector()
should be considered to be "in the context of a shadow tree").

I've just defined the term "in the context of a shadow tree" in the
spec, and left an issue that we need to get DOM to hook the term for
querySelector().

> But this makes me wonder how one of the examples in the spec works.
> http://drafts.csswg.org/css-scoping/#host-element-in-tree explicitly
> says that one of the goals of these selectors is styling the shadow
> host (rather than just selecting its descendants based on something
> about it).
>
> Given that, it's not clear to me how this intends the matching and
> application of style rules to work.  What makes the selectors that
> come from a style or link element inside the shadow tree be applied
> when deciding what styles apply to the host element, when everything
> seems to say that they apply only inside the shadow tree?

The very section you link explicitly says that the host element is
considered as being in the shadow tree for the purpose of matching
selectors.  That's the entire topic of the second paragraph.

~TJ
Received on Wednesday, 25 March 2015 21:46:12 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:39:30 UTC