W3C home > Mailing lists > Public > www-style@w3.org > February 2013

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

From: Garrett Smith <dhtmlkitchen@gmail.com>
Date: Wed, 6 Feb 2013 21:01:04 -0800
Message-ID: <CABZUbM0MafGBeU4b87hOcEZhVbkxO2Qg6MwpN3Xh=KVwG-=ctA@mail.gmail.com>
To: Mike Sherov <mike.sherov@gmail.com>
Cc: "www-style@w3.org" <www-style@w3.org>
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


"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!

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.
Twitter: @xkit
Received on Thursday, 7 February 2013 05:01:32 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:26 UTC