Re: CSSStyleDeclaration: Setting only a value or a priority

On Thu, 22 Aug 2013 00:14:40 +0200, L. David Baron <dbaron@dbaron.org>  
wrote:

> On Wednesday 2013-08-21 14:58 -0700, Tab Atkins Jr. wrote:
>> On Wed, Aug 21, 2013 at 2:46 PM, L. David Baron <dbaron@dbaron.org>  
>> wrote:
>> > I think this is a really bad idea (which has apparently now made its
>> > way into the spec according to comments in
>> > https://bugzilla.mozilla.org/show_bug.cgi?id=903239 , although I
>> > don't see any mention in this thread of it).
>> >
>> > The underlying mental model of setProperty has, I think, always been
>> > "append declaration".  The object model of declaration blocks was
>> > designed without an idea of preserving order; setProperty appends a
>> > declaration to the end.  Thus setProperty with no priority being a
>> > no-op if the declaration block already has an !important declaration
>> > for that property.
>>
>> I don't think it's ever been clear that the mental model was "append a
>> declaration".  The style OM is, as you say, an unordered dict.  The
>> underlying data has an order, but we lose that detail, along with
>> several others, in the translation to the OM.  Preserving the ordering
>> quality in one, somewhat hidden, way seems like a recipe for
>> confusion.
>
> Also, we're going to need to change to preserving order in order to
> support logical properties.  Having things like margin-start,
> margin-before, etc., requires preserving their order relative to
> margin-left, margin-top.  So all CSSOM operations on declarations
> will need to define what effect on order they have.

CSSOM already preserves and exposes the order of different properties  
within a declaration block.

http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2473
vs
http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2474

See http://dev.w3.org/csswg/cssom/#concept-declarations-specified-order

http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-setproperty also  
specifies what effect on the order it has.

cheers
-- 
Simon Pieters
Opera Software

Received on Thursday, 22 August 2013 08:08:58 UTC