Optimizing CSS removeProperty()

Harri Porten porten at kde.org
Sun Aug 24 17:32:19 BST 2008


Hello,

the DOM spec[1] mandates the removeProperty() CSS function to return the 
value of the property that is being removed. We use this function in 
several places and never care about the return value. The usage is mostly 
about replacing like in setProperty().

Now, fetching the return value can involve some computation - done for 
nothing. To speed up setProperty() and addParsedProperties() I'd like to 
ommit the computation of this return value. The question is just how to do 
this most elegantly. Some solutions I can think of:

1.) Provide a second justRemoveProperty() function (drawback: code 
duplication, particularly since removeProperty() is virtual).

2.) Add a "noReturnValue" flag causing an empty string to be returned 
(drawback: uglifying the code a bit).

3.) Drop the return value from removeProperty() from the internal 
implementation, i.e. make it a void function and implement the public DOM 
API in terms of a getPropertyValue() and removeProperty() pair. (drawback: 
would slow down real removeProperty() calls. but who every calls that?).

Another alternative might be to implement setProperty() at al without 
removeProperty(). But this would require some care to get it right I 
guess.

What do you think? Allan?

Harri.

[1] 
http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/css.html#CSS-CSSStyleDeclaration-removeProperty




More information about the kfm-devel mailing list