W3C home > Mailing lists > Public > www-style@w3.org > September 2009

Re: Proposal: getStyleAs(property, primitiveValue)

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Tue, 22 Sep 2009 11:38:19 -0500
Message-ID: <dd0fbad0909220938n3bad1ab6td21b82168530d78@mail.gmail.com>
To: Garrett Smith <dhtmlkitchen@gmail.com>
Cc: www-style <www-style@w3.org>
On Tue, Sep 22, 2009 at 11:27 AM, Garrett Smith <dhtmlkitchen@gmail.com> wrote:
> New Proposal:
> var height = x.getStyleAs("height", "px");
> height = parseInt(height, 10);
>
> For color:-
> var color = x.getStyleAs("color", "rgba");
> if(!color) {
>  // failed.
>  color = x.getStyleAs("color", "rgb");
> }
>
> This addresses the problem of reading a style value. The
> primitiveValue is defined in the relevant CSS specification for the
> property.

I highly support this, as I've currently got a program that's both
slightly broken (because I don't hack around the issue for lengths)
and annoyingly complicated (because I do hack around the issue for
colors).  The color issue is especially annoying, since I'm having to
reimplement a full <color> parser in my PHP.  IIRC, every single
rendering engine returns something different when I do
$(elem).css("color") for an element with "color:blue" set in CSS.

> A corresponding method to set a value would not seem to be necessary,
> as any value could be set with:
>
> x.style.color = "papayawhip";

Hahaha, this makes me laugh every time.

~TJ
Received on Tuesday, 22 September 2009 16:39:16 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:21 GMT