Re: CSSStyleDeclaration: Setting only a value or a priority

On Thu, 22 Aug 2013 17:56:27 +0200, L. David Baron <dbaron@dbaron.org>  
wrote:

> On Thursday 2013-08-22 08:13 +0200, Simon Pieters wrote:
>> On Wed, 21 Aug 2013 23:46:04 +0200, 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).
>>
>> http://lists.w3.org/Archives/Public/www-style/2013Aug/0297.html
>
> Sorry, missed the one-liner in the midst of the quote.
>
>> >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.
>>
>> setProperty with no priority was *not* a no-op in the previous spec.
>> Instead, it would set the value and unset important. This is what
>> Gecko (and Presto) implements also.
>>
>> http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2472
>
> OK, I guess it was originally implemented that way but changed in
> https://bugzilla.mozilla.org/show_bug.cgi?id=556661 .

The reporter of that bug clearly has a different mental model about what  
setProperty should do.

> I guess I
> should have thought about that more carefully.  I'd probably prefer
> to revert that change.
>
>> It's no-op in WebKit/Blink/IE, though.
>>
>> As I said before I made the change, I can see an argument for why
>> no-op behavior can be desirable, and asked if we should change the
>> spec to do that. Nobody replied to that.
>>
>> http://lists.w3.org/Archives/Public/www-style/2013Aug/0247.html
>
> Sorry; I basically can't keep up with everything on www-style.

I don't blame you. :-)

> Nonetheless, I object to the attempt to implement this
> undefined/empty string difference in Gecko, which I think is a bad
> idea, and don't plan to accept.

OK. Since that was the traditional behavior in Gecko and other browsers  
still have it (except Presto), I'm OK with embracing it in the spec.

So assuming that's the model for setProperty, we have the following  
options presented for addressing the original use case:

2) Providing "unchanged" as third argument: clear, but leads to additional  
string argument parsing.
3) Adding a "setPropertyValue" function to the spec: no compatibility  
issues, slightly faster, clear meaning, symmetric to "getPropertyValue".

(2) doesn't really make sense with this setProperty model, so that leaves  
(3). (3) still doesn't quite fit in in the model, but could maybe be  
called something else. Are there other options, or other ways to address  
the use case? Or do you think the use case is not important so it's OK to  
require the call to getPropertyPriority?

-- 
Simon Pieters
Opera Software

Received on Thursday, 22 August 2013 16:49:43 UTC