Re: [shadow-styling] matching rules for complex selectors beginning with :host and :ancestor

On Wed, Mar 12, 2014 at 5:39 PM, Steve Orvell <sorvell@google.com> wrote:
> The spec here:
>
> http://dev.w3.org/csswg/shadow-styling/#host-selector
> http://dev.w3.org/csswg/shadow-styling/#ancestor-selector
>
> does not match my understanding of how these features were originally
> envisioned. Specifically, as mentioned in the spec in section 5.3 example 6,
> an author wants to be able style elements in shadowRoot conditionally based
> on how the host or an ancestor of the host is styled. This not only allows
> for a type of theming, but also allows other types of styling based on other
> external conditions. For example:
>
>  * a menu-item that looks one way when it's inside a menu and another way
> inside a popup-menu.
>  * a list-item that has an icon inside it that lights up when the list-item
> itself has a "selected" class.
>  * an input type element that has special internal styling when it's host
> element has a `disabled` attribute.
>
> As currently spec'd, it looks like :ancestor should be useful for some of
> this, but it doesn't work for styling that's influenced only by the host
> element.
>
> When proposed, my understanding of :ancestor was that it would be
> *identical* to :host except that the argument in the parens could match
> anywhere in the element's lineage (precisely as is defined in the spec now).

I'm unsure about what I'd written about :ancestor before, but as of
this moment, :host-context() (the new name for :ancestor()) is indeed
exactly equivalent to :host(), except that it reaches further up the
tree.

~TJ

Received on Saturday, 22 March 2014 00:33:06 UTC