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

Re: CSSStyleDeclaration: Setting only a value or a priority

From: L. David Baron <dbaron@dbaron.org>
Date: Wed, 21 Aug 2013 14:46:04 -0700
To: Simon Pieters <simonp@opera.com>
Cc: "www-style@w3.org" <www-style@w3.org>, Peter Sloetjes <pjs.nl@live.com>
Message-ID: <20130821214604.GA29161@crum.dbaron.org>
On Thursday 2013-08-15 22:30 +0200, Simon Pieters wrote:
> On Mon, 12 Aug 2013 21:57:21 +0200, Peter Sloetjes <pjs.nl@live.com> wrote:
> 
> >>> For the purpose of faster and simpler low level style
> >>transformations, I
> >>> would like to see either:
> >>> 1) the CSSStyleDeclaration interface to be extended with the functions
> >>> 'setPropertyValue' and 'setPropertyPriority', or
> >>> 2)
> >>>  the CSSStyleDeclaration.setProperty function to accept 'null' for the
> >>> property value or property priority as an indication that the
> >>> value/priority should not be changed.
> >>
> >>For (2), currently null for the value means that the declaration
> >>is to be
> >>removed and null for priority means that !important gets unset.
> 
> >As you note, the second solution I proposed is not feasible, hence
> >the preferred solution would be to add 'setPropertyValue' and
> >'setPropertyPriority' functions to the CSSStyleDeclaration
> >interface, for symmetry & speed.
> 
> Another option is to let setProperty(value) i.e. with the second
> argument omitted leave the priority alone. This would be a change in
> behavior, but the current behavior seems unexpected and is likely to
> result in buggy code. Does anyone know if there are pages that would
> break if setProperty(value) (or with the property = value; syntax)
> would *not* unset !important ?

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 also think the use case is really obscure, and having to make an
extra function call to address it (as today) is fine.  I don't see
strong evidence that we need to change the Web platform to address
it.

Please revert this spec change.

-David

-- 
𝄞   L. David Baron                         http://dbaron.org/   𝄂
𝄢   Mozilla                          https://www.mozilla.org/   𝄂
             Before I built a wall I'd ask to know
             What I was walling in or walling out,
             And to whom I was like to give offense.
               - Robert Frost, Mending Wall (1914)

Received on Wednesday, 21 August 2013 21:46:36 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 21 August 2013 21:46:37 UTC