Re: Proposal: getStyleAs(property, primitiveValue)

On Tue, Sep 22, 2009 at 11:27 AM, Garrett Smith <> 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:
> = "papayawhip";

Hahaha, this makes me laugh every time.


Received on Tuesday, 22 September 2009 16:39:16 UTC