RE: CSSStyleDeclaration: Setting only a value or a priority

On Mon, 12 Aug 2013 08:57:19 +0200, Simon Pieters <simonp@opera.com> wrote:

> Can you explain a case where you would want to do this?

My main use case is a full-document color transformation, which applies some algorithm to all non-empty color property values (but many similar use cases could be imagined). In this application, getPropertyPriority has to be called when writing back the transformed value using setProperty, because changing a property priority might have very annoying consequences (such as unreadable text). Since the transformation might apply to a huge amount of property values, any unnecessary function calls should be avoided for reasons of speed.

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..

> PJS, Firefox add-on developer.

----------------------------------------
> To: www-style@w3.org; pjs.nl@live.com
> Date: Mon, 12 Aug 2013 08:57:19 +0200
> From: simonp@opera.com
> Subject: Re: CSSStyleDeclaration: Setting only a value or a priority
>
> On Sat, 10 Aug 2013 17:32:33 +0200, Peter Sloetjes <pjs.nl@live.com> wrote:
>
> > The current specification of CSSStyleDeclaration.setProperty makes it
> > necessary to call either
> > 'getPropertyPriority' or 'getPropertyValue' in case only a property
> > value or a property priority is to be modified.
>
> Can you explain a case where you would want to do this?
>
> > 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.
>
> > PJS, Firefox add-on developer.
>
>
> --
> Simon Pieters
> Opera Software
> 		 	   		  

Received on Monday, 12 August 2013 20:20:50 UTC