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

Re: [CSSOM] GetComputedStyle : choose the unit

From: Garrett Smith <dhtmlkitchen@gmail.com>
Date: Mon, 23 Mar 2009 11:07:02 -0800
Message-ID: <c9e12660903231207y5fdc8303u32d945fbb78ae84f@mail.gmail.com>
To: Ludger Buenger <ludger.buenger@realobjects.com>
Cc: Innovimax SARL <innovimax@gmail.com>, www-style@w3.org
On Mon, Mar 23, 2009 at 10:20 AM, Ludger Buenger
<ludger.buenger@realobjects.com> wrote:
> This is already possible in a slightly different way, so please read the
> fine standard!
> Try this:

In what? Not a browser, obviously.

If changed to:-

var prop = document.defaultView.getComputedStyle(document.body,
var value = prop.getFloatValue(CSSPrimitiveValue.CSS_PX);

It would work in some browsers. Replacing CSS_PX with CSS_EM should
result in error.

CSS_EMS might work in some browsers.

The API is designed in a way that pretty much requires try-catch because:-

| getFloatValue
|    This method is used to get a float value in a specified unit.
| If this CSS value doesn't contain a float value or can't be converted
| into the specified unit, a DOMException is raised.

It doesn't work reliably. What happens if an error is thrown?

> For convenience, I omitted instance, type null and other checks…

I am not saying you have a bad idea, but can you explain why you need
this to work?

> Ludger


Received on Monday, 23 March 2009 19:07:38 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:38:25 UTC