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

On Mon, Aug 5, 2013 at 2:48 PM, Mike Sherov <mike.sherov@gmail.com> wrote:
> On Wed, Jul 3, 2013 at 3:41 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
>> Talking this over with fantasai on Monday, we've come to the
>> conclusion that it's probably not a good idea to expose .usedStyle at
>> this point, for two reasons:
>>
>> 1. Not all properties *have* a used style.  If a property doesn't
>> apply to an element, we don't define what the used value is.  You
>> could just say that it's the same as the computed value in that case,
>> but that's just filling in a hole with something meaningless; there's
>> still not really any concept of "used value" for the property.
>
> This may be the wrong place to ask this, but what do you mean by "If a
> property doesn't apply to an element"? I was under the impression that an
> empty string would indicate this if I'm understanding correctly. For
> example, the used and computed values of a detached element are all empty
> strings because none of the properties apply to the element. I could be
> misunderstanding here.

For example, 'flex-basis' only applies to flex items.  If you're not a
flex item, we can't figure out what "auto" should resolve to, since
you don't have a corresponding flex container with a 'flex-direction'
value.

Empty string, or something else like null, might be sufficient for these cases.

>> 2. We can do *so much better* at used-value time. At that point we
>> have all the necessary information to expose lengths in *any* unit you
>> ask for, rather than just px.
>>
>> Because of this, fantasai and I think we should hold on doing
>> .usedStyle, in favor of pursuing the long-discussed idea of the Values
>> API, which allows asking rules for their values in various units.
>
> My original naive proposal begs for the values API as well. As long as I can
> get "auto" vs. "50%" vs. "50px" whenever I want for the "actual" value of
> the property on an element, I think we're good. What would that look like?

That's the million-dollar question.  ^_^  Anne sketched out a possible
solution for this at
<http://www.w3.org/TR/2011/WD-cssom-20110712/#the-csspropertyvalue-interface>.
 If you have trouble reading vaguely-sketched out WebIDL, let me know
and I can provide some examples.  ^_^

~TJ

Received on Monday, 5 August 2013 22:18:03 UTC