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

Re: [css-scoping] Shadow Cascading

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Fri, 6 Feb 2015 08:02:10 +1100
Message-ID: <CAAWBYDDnp6ZxQnw4tsL1AfHtU=faH420mLYWCu+LJWprMHhJFA@mail.gmail.com>
To: Rune Lillesveen <rune@opera.com>
Cc: Hayato Ito <hayato@google.com>, www-style list <www-style@w3.org>
On Fri, Feb 6, 2015 at 12:30 AM, Rune Lillesveen <rune@opera.com> wrote:
> On Thu, Feb 5, 2015 at 12:33 AM, Rune Lillesveen <rune@opera.com> wrote:
>> On Wed, Feb 4, 2015 at 11:52 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
>>> On Thu, Feb 5, 2015 at 9:38 AM, Hayato Ito <hayato@google.com> wrote:
>>>> Looks like the current spec wants to say:
>>>>
>>>> 1. The Origin and Importance matters
>>>> 2. [Shadow Tree] The outer wins the inner (only when there is an
>>>> ancestor/descendant relationship between two node trees)
>>>> 3. [Shadow Tree] The younger wins the older (only when they are hosted by
>>>> the same shadow host)
>>>> 4. Specificity matters
>>>> 5. Order of Appearance in tree-of-trees matters
>>>
>>> Yes.  As far as I can tell, that's *exactly* what the spec is saying.
>>> Is there anything unclear?
>>
>> No, it's clear now.
>
> I'm sorry, but I'm afraid it isn't. There seems to be a circularity
> here. Consider:
>
> <!DOCTYPE html>
> <div id="outerHost">
>     <div id="innerHost">
>         <div id="t" class="t">Which color do I have?</div>
>     </div>
> </div>
> <script>
> var outerRoot = outerHost.createShadowRoot();
> var innerRootOld = innerHost.createShadowRoot();
> var innerRoot = innerHost.createShadowRoot();
>
> outerRoot.innerHTML = "<style>::content #t { color: red
> }</style><content></content>";
> innerRootOld.innerHTML = "<style>::content #t.t { color: green
> }</style><content></content>";
> innerRoot.innerHTML = "<style>::content .t { color: blue
> }</style><shadow></shadow>";
> </script>
>
> Given rules in outerRoot(1), innerRootOld(2), and innerRoot(3) respectively.
>
> - None of the scopes has a parent-child relationship in the tree-of-trees.
> - (2) beats (1) due to specificity
> - (1) beats (3) due to specificity
> - (3) beats (2) because it's younger

No, you're misusing the cascade.  It produces an ordering by applying
the rules in the order specified.  The Shadow Tree rules produce only
a partial ordering, but still.

In this example, then:

1. Origin doesn't matter.  All three are still unsorted.
2. Shadow Tree Ancestor doesn't matter.  All three are still unsorted.
3. Shadow Tree Age sorts #3 ahead of #2.  #1 is still unsorted relative to them.
4. Specificity sorts #1 ahead of #3. You now have a total ordering.

~TJ
Received on Thursday, 5 February 2015 21:03:01 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:52:01 UTC