Re: <style scoped> and the cascade

On 3/7/12 11:22 PM, Leif Halvard Silli wrote:
> Boris Zbarsky, Wed, 07 Mar 2012 22:10:28 -0500:
>
>> No.  For example, I would think that inline style on a node should
>> override<style scoped>.
>
> I see that you parse my language like a computer ...

More precisely, I treat your language like a spec text proposal.

> I of course did not intend to convey that<style scope>  should overrule the @style
> attribute.

I don't know what you _intended_ to convey, but you did in fact convey 
that it should do just that....

>>> Examples: Imagine we have<foo-root>   element as direct child of<body>.
>>> And imagine that we have a global<style>   in the<head>   with the
>>> following rule:
>>>
>>>      body foo-root {background:red}
>>>
>>> Simultaneously, inside a<style scoped>   inside the<foo-root>, we have
>>> this rule:
>>>
>>>      foo-root{background:lime}
>>>
>>> Problem: In this case the global style would win.
>>
>> Not with my proposal.  That's the whole point of my proposal!
>
> Either you did not understand my proposal, or I have missed something
> in yours.
>
> So what is it in your proposal that makes the scoped style *in the
> above example* win?

The fact that any rule in scoped style wins over any unscoped rule 
(ignoring the effects of !important) with my proposal?  That's all the 
proposal is about.

> I see nothing here:
> <http://lists.w3.org/Archives/Public/public-html/2012Mar/0228.html>

The list of the order in which rules are applied in that mail seems 
pretty clear to me.

> Note that in my example above, then - according to the current rules,
> the global style [from the<style>  in the head] is more specific than
> the local, scoped style.

Yes, and I'm proposing changing those rules.

> Note as well, that with the proposal that I
> tried to present, then this would not be the case: In my proposal, then
> the two rules above, would have - to quote CSS2 - 'the same weight,
> origin and specificity'. Thus, the scoped style would win only because
> it follows *after* the global style.

OK.  That's quite different from my proposal, and I think is much more 
fragile.

In my proposal the scoped rule would win no matter what the 
specificities are.

>   ''2)  Styles from "a" and "c" (sorted by specificity, etc)''
>
> Unfortunately, you did not include any rules, so I could understand how
> you would count specificity for<style scope>.

It wasn't relevant to the discussion.

> But I would suggest,
> that if we had this:
>
> <div>
>      <style id="a" scoped>* *{color:red}</style>
>      Lorem
>      <p>
>        <style id="b" scoped>*{color:blue}</style>
>        Ipsum
>      </p>
> </div>
>
> Then the rule inside #b would have the same specificity as the rule
> inside #a.

In my proposal the rule inside "b" would have higher specificity, 
effectively.  More precisely, it would be in a different cascade level, 
and sort by cascade level happens before sort by specificity.

-Boris

Received on Thursday, 8 March 2012 05:30:50 UTC