Re: [shadow-styling] /content/ is cumbersome v. ::content

On Mon, Mar 17, 2014 at 2:24 PM, Steve Orvell <sorvell@google.com> wrote:
> Let's say an author wants to style all `div`'s within the subtree selected
> to a given insertion point. Correct me if I'm wrong, but it seems like this
> selector would be required:
>
> content /content/ div, content /content/ * div { ...}
>
> This is based on the definition of the /content/ combinator here:
> http://dev.w3.org/csswg/shadow-styling/#content-combinator.
>
> Previously, the ShadowDOM spec defined a pseudo-element ::content for
> matching the content element. With this pseudo-element, to write a selector
> which matched the same set of elements would have been:
>
> ::content div { ... }
>
> This is certainly a win for brevity.
>
> If it's important to restrict a selector to the set of distributed elements,
> you can use the child combinator. In other words, these would be equivalent:
>
> content /content/ div { ... }
> ::content > div { ... }

Well, you don't need to specify the "content" beforehand in the first
selector.  You need *something*, but it can just be "*":

* /content/ div {...}
::content > div {...}

Things without a distribution list just won't match anything when the
combinator is applied.

> This makes me think a pseudo-element would be superior for matching
> distributed elements.
>
> Are there other reasons to prefer a combinator?

Consistency with the other combinators.

~TJ

Received on Monday, 17 March 2014 21:30:32 UTC