W3C home > Mailing lists > Public > www-style@w3.org > August 2013

Re: CSSStyleDeclaration: Setting only a value or a priority

From: Simon Pieters <simonp@opera.com>
Date: Fri, 23 Aug 2013 10:17:08 +0200
To: "Zack Weinberg" <zackw@panix.com>, "L. David Baron" <dbaron@dbaron.org>
Cc: "www-style@w3.org" <www-style@w3.org>, "Peter Sloetjes" <pjs.nl@live.com>
Message-ID: <op.w19fyup0idj3kv@simons-macbook-pro.local>
On Fri, 23 Aug 2013 01:39:26 +0200, L. David Baron <dbaron@dbaron.org>  
wrote:

>> Since that was me ...
>>
>> David, I think you've let the guts of Gecko's implementation color
>> your thinking a little too much.  Specifically, the fact that Gecko
>> maintains separate "declaration blocks" for !important and normal
>> properties from the same style rule is an artifact of the
>> implementation that should *not* IMNSHO be visible to style authors.
>> Style authors should be presented a unified view in which any given
>> rule has only one value for any given property, which may or may not
>> have its !important bit set.
>
> I don't think the mental model is at all related to the storage;
> I've had that mental model since before we took that approach for
> storage.  And I also dislike that approach for storage and would
> prefer to have them stored together.
>
>> As such, setProperty(prop, value, "") should be thought of *not* as
>> "appending a new property-value pair to the style rule, which may then
>> override an earlier pair" but as "*replacing* the existing value for
>> 'prop', if any, otherwise setting it anew". I believe this is the most
>> natural mental model.
>
> It's pretty odd once you have margin-left interacting with
> margin-start, though, since then (in LTR),
> setProperty("margin-left", "...") will override a margin-before in
> the same declaration block *unless* there was a pre-existing
> margin-left declaration that was before the margin-before
> declaration.  That's pretty odd.

But that's the behavior the spec has and that browsers have as well (I  
can't test IE right now but IIRC it does this also).

http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2480

Note that color is still first in the list.

Now, in the case of margin-left vs margin-start...

http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2481

The order in CSSOM is unchanged in both Gecko and Blink. Gecko uses  
margin-left while Blink uses margin-start. So in this case Gecko ends up  
in a state where the order exposed by CSSStyleDeclaration doesn't match  
what Gecko actually uses.

It's unclear to me why margin-left vs margin-start depends on the order  
instead of e.g. always letting margin-start win.


>> (Relatedly, I think the behavior of
>>
>>    p { color: green !important; color; red }
>>
>> is surprising and inconsistent with the rest of CSS, and should
>> probably be changed so the textually-last property clobbers the
>> !important one.)

We can't change this I think.

> I think CSS1 and CSS2 are both pretty clear that:
>   p { color: green !important; color: red }
> is intended to simply be a shorthand for:
>   p { color: green !important }
>   p { color: red }
>
> http://www.w3.org/TR/CSS1/#grouping
> http://www.w3.org/TR/CSS2/syndata.html#declaration
>
> While what you propose is perhaps a consistent model, it's
> inconsistent with the stated intent of declaration blocks in CSS.

I'm not convinced that setProperty necessarily needs to be consistent with  
how declarative CSS works.

-- 
Simon Pieters
Opera Software
Received on Friday, 23 August 2013 08:11:39 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:33 UTC