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

On 1/27/13, Mike Sherov <mike.sherov@gmail.com> wrote:
Hi Mike -

> Forgive my ignorance on the subject, and please correct me where I'm wrong
> or missing information or where something exists that does these things
> already...
>
I'm happy you brought it up. See here: Re: getComputedStyle vs. getCascadedStyle

http://lists.w3.org/Archives/Public/www-dom/2000JulSep/0039.html

"Re: Should IE drop currentStyle/ runtimeStyle?"

| The proposal of getCascadedStyle would cause much less damage
| by putting the method directly on window, and not exposing it to
| document.defaultView.

The only problem with me proposing anything is that it is less likely
to become implemented.

> The web development community at large currently seems to be beholden to
> getComputedStyle() as the only source of information of what styles are
> applied to an element. The resulting CSSStyleDeclaration seems to represent
> a significant loss of information by presenting only the "resolved values"
> of the styles.
>

>
> For example, consider this jQuery UI bug:
No thanks.


>
> In general, it seems as if this one view, getComputedStyle(), can't tell me
> enough information to accomodate everything I want to know. Now, I'm no
> spec writer, but in a perfect world I'd want:
>
> window.getStyle(valueType, element[, psuedoElement]);
>
Ah, value converter. Something like that would be nice. I've
championed the idea in the past and will do so now. HOpefully not to
curse it!
http://lists.w3.org/Archives/Public/www-style/2009Nov/0348.html

There've been many more discussions on this matter with which devolved
into utter nonsense.

> and separately a new parameter on CSSStyleDeclaration.getPropertyValue:
>
> CSSStyleDeclaration.getPropertyValue( propertyName[, unit, valueType]);
>
IIRC one of my proposals on css mailing list: getValueAs.

> This would allow me to query any of the values I'd like:
> "default","initial","specified","computed","used","actual", and "resolved".
> getComputedStyle(elem) would be equivalent to  getStyle("resolved", elem).
> I'd
> also now be able to convert units or value type if I wanted, simply by
> specifiying it as the second and third parameter to getPropertyValue!
>
Right. Most of the time you just want px, but if the unit is specified
in em, you want that in px and not auto.
-- 
Garrett
Twitter: @xkit
personx.tumblr.com

Received on Thursday, 7 February 2013 05:01:32 UTC