Re: [cssom] Proposal for obtaining robust style information via Javascript - getStyle()

On Thu, Jan 31, 2013 at 9:35 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:

> On 1/31/13 9:23 PM, Tab Atkins Jr. wrote:
>
>> Wait, getComputedStyle is a live object?
>>
>
> Yes.  And yes, that makes it an incredible pain to implement.
>
>
>  Nah, let's just return a dead object.  It's for when you do need to
>> request multiple
>> properties, without having to retype the function multiple times (or
>> get the UA to recompute things multiple times, if it can save effort
>> by combining things).
>>
>
What I'd say is that you almost never want all properties, but really a
subset. If you want users to not have to type so much, than make the first
argument accept either a string (single property) or array (multiple
properties) or null (all properties). I suppose "null" is an ugly, terrible
way to indicate you want all props of that type, but we can solve that with
the dictionary signature.


> There's a good chance that returning a dead object, which must therefore
> have computed values for all the properties, will take more time than
> computing 2 or 3 property values even if you have to duplicate some work...
>  A quick glance in Gecko suggests that we currently support about 300
> properties, not counting shorthands.  And I would expect that number to
> grow significantly if the current pattern of css3/4 modules breaking up
> existing properties into 4-5 shorthands continues.


> Maybe UAs can internally optimize by returning an object which can produce
> dead values of properties on demand but doesn't actually compute them until
> asked...  Gecko can sort of do that maybe, at times, kinda (yes, lots of
> caveats).  Can't speak for others.


> In any case, seems like this use case argues for being able to not pass a
> property name but still pass in a value type and pseudo-element, right?
>  That does argue for using a dictionary for the argument...


>
> -Boris
>
>


-- 
Mike Sherov
Lead Developer
SNAP Interactive, Inc.
Ticker: STVI.OB

Received on Friday, 1 February 2013 02:48:18 UTC