Re: Fwd: cssom - clientTop, et v

On Mon, 10 Mar 2008 06:24:46 +0100, Garrett Smith <dhtmlkitchen@gmail.com>  
wrote:
> Puts the 'px' in the wrong place. It complicate scripts that properly
> typecheck:-
>
> if(typeof el.currentStyle.borderRightWidth == "string") {
>
> }

Do you know of any site that does that? I'd love to have some pointers.


> The real "use case" for (3) is for hand-rolled javascript based
> animations. [...]

Indeed. There seem to be various other proposals for animations now that  
make it worthwhile delaying extensions to the CSSOM. (CSS Animations and  
SVG Animation.)


> I did not find the currentStyle specified in the CSSOM draft
> (http://www.w3.org/TR/cssom-view/), so I googled and found:
> http://dev.w3.org/csswg/cssom/
> This document appears to be outdated. Please confirm. What is the  
> correct URI?

That is the correct URI. I'm not updating everything at the same time ;-)


> [...]
> Element.getComputedValueAs(property, desiredUnit), would avoid this
> painful and limited approach. It would open other possibilities.

How does that work for properties that don't take units, but keywords? Or  
properties that take <color> values?


> Of the three possible methods, which are the most useful? This is an
> open question to anyone now - post up and speak your mind. Let's hear
> it.
>
> Case (1) el.cascadedStyle - get the cascaded style
>
> Keywords are not useful. "Inherit" is not useful.
> Implementations of currentStyle sometimes return keywords or "inherit".
>
> Why currentStyle's Keywords are Undesirable -
> In IE and Opera, currentStyle return values are not clearly defined
> and, in many cases, returns values that are undesirable. Such
> undesirable values are "auto", "", "inherit", "medium", "bold" and
> other keywords. When I get an undesirable value like "inherit", I
> usually want the inherited value. For animation, it's not possible to
> perform math on "inherit" -- i need a number. So I have to check the
> parentNode, then the parentNode of the parentNode, all the way up
> until I get a value. If the value is the keyword "red", I degrade. I
> do not believe in sending down the wire a javascript colorKeyword ->
> hex map. The browser should do the conversion.

That sounds reasonable. I've added a note about cascadedStyle.


> Regarding "CSS Pixel" - Is this a floating point number, a floating
> point number as a string with "px", a rounded number, or a rounded
> number plus "px"?

A CSS pixel is a CSS pixel. The representation depends on the context.


> [ getComputedStyle examples ]
>
>> A new API doesn't solve any problems we have with the existing APIs. It
>> just adds more. Whether we like it or not, clientTop is part of the Web.
>
> Adding a new API creates fewer problems because the existing API can
> be replaced with something that is more consistent across browsers.

It can be not be replaced. Browsers have to support both. Hence, more  
problems.


-- 
Anne van Kesteren
<http://annevankesteren.nl/>
<http://www.opera.com/>

Received on Monday, 10 March 2008 07:59:25 UTC