Re: DOMString-like objects for the CSSOM

On Feb 23, 2010, at 2:49 AM, Anne van Kesteren wrote:

> On Sat, 20 Feb 2010 02:22:12 +0100, Maciej Stachowiak  
> <mjs@apple.com> wrote:
>> The other alternatives involve creating some parallel API, along one
>> of the following lines:
>>
>> foo.style.topValue.px = 200
>> foo.style.topPX = 200
>> foo.styleValues.top.px = 200
>>
>> Of these options, I think the last one is probably the best, because
>> it's easy to feature-test for from script. The only problem is that
>> "styleValues" is kind of a bad name. I'm sure there are better
>> possibilities though.
>
> I guess we should do something like that then.
>
> I personally think a new member on CSSStyleDeclaration would be  
> better so we do not need to introduce a whole new series of  
> accessors. Thoughts?

Good point, that would also make it work with getComputedStyle and the  
like. So something like:

foo.style.values.top.px
foo.style.properties.top.px

This does mean one extra property access compare to foo.style.top.px,  
and two more compared to foo.style.top. However, for repeated style  
access an author could (presumably) save foo.style.properties in a  
variable and just do properties.top.px.

Regards,
Maciej

Received on Tuesday, 23 February 2010 22:10:40 UTC