Re: [cssom] overwriting an important style

On Mon, 08 Sep 2014 05:19:12 +0200, Mike Sherov <mike.sherov@gmail.com>  
wrote:

> Apologies if I've overlooked something, but it appears from the spec  
> that there is no single method that can be invoked on an elements style  
> declaration to change it from (e.g.) "color: red !important" to "color:  
> black".
> Step 3 of http://dev.w3.org/csswg/cssom/#append-a-css-declaration says:  
> "If declaration has its important flag set and the important flag is not  
> set, terminate these steps."
>
>
> It seems that in order to change from "color: red !important;" to  
> "color: black;", one should be able to say "elem.style.color = 'black';"  
> or at the very least "elem.style.setProperty('color', 'black', '');"
>
>
> However, the way the spec is written (and the way all but FF implement),  
> the following is required: "elem.style.setPropertyPriority('');  
> elem.style.setPropertyValue('black');"
>
>
> What's the reason for this termination step and not allowing for  
> elem.style.setProperty('color', 'black', ''); to work once the important  
> flag has been set on a declaration?

https://www.w3.org/Bugs/Public/show_bug.cgi?id=23066

The idea is that your mental model should be that setProperty('color',  
'black', '') is equivalent to appending a color:black; declaration to the  
style rule, which doesn't win over the !important one.


> Can this be changed?

If you can convince David Baron... :-)

-- 
Simon Pieters
Opera Software

Received on Monday, 8 September 2014 07:32:52 UTC