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

Re: Proposal: getStyleAs(property, primitiveValue)

From: Giovanni Campagna <scampa.giovanni@gmail.com>
Date: Tue, 22 Dec 2009 13:53:20 +0100
Message-ID: <65307430912220453q3596f2f6q51cfa456bfe0c271@mail.gmail.com>
To: Patrick Garies <pgaries@fastmail.us>
Cc: Garrett Smith <dhtmlkitchen@gmail.com>, Travis Leithead <travil@microsoft.com>, www-style <www-style@w3.org>
On Tue, Dec 22, 2009 at 10:30 AM, Patrick Garies <pgaries@fastmail.us> wrote:
> On 9/22/2009 8:08 PM, Garrett Smith wrote:
>>>
>>> I also assume that getStyleAs can return a plethora of possible values
>>> from strings to other interfaces...
>>>
>>
>> I was thinking it would return a string although |asNumber| param
>> might a possibility:-
>>
>> x.getStyleAs("length", "px", "number");
>>
>> Returns a number representing the length, in css pixels.
>
> For some reason, I'm thinking Travis was wondering what all the types of
> returnable values are. So far, pixels, integers, and RGBA seem to be covered
> based upon your examples. |rgb| is also mentioned, but it's not clear if
> that's a reference to the hexadecimal or functional notation.
>
> The above code also seems overly complex IMHO. I can't tell what |"length"|
> is for. |x.getStyleAs("pxint")| or |x.getStyleAs("px", "int")| seem simpler;
> both output a pixel value as an integer. (I assume |x| is a reference to
> something like |element.style.margin| or am I mistaken?)
>

I think that x is someelement.style, and "lenght" is a just "a length
property" (for example margin-top, float-offset or font-size). In
fact, maintaing the invariant x.margin === "10px auto 10px auto" and
typeof x.margin === "string" was one of the reasons for getValueAs
instead of the simpler x.margin.px, which requires margin being an
object

Giovanni
Received on Tuesday, 22 December 2009 12:54:13 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 22 May 2012 03:47:12 GMT