Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news1.tnib.de!feed.news.tnib.de!news.tnib.de!news.belwue.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="UTF-8" Message-ID: <1395223.HDI7Dnh15d@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Sat, 11 Feb 2012 15:21:52 +0100 User-Agent: KNode/4.4.11 Content-Transfer-Encoding: 8Bit Subject: Re: getComputedStyle vs currentStyle with IE 9 Newsgroups: comp.lang.javascript Followup-To: comp.lang.javascript References: <2541188.UZlinSPExI@PointedEars.de> <0ZKdnfcGHO2Bj6jSnZ2dnUVZ_rSdnZ2d@westnet.com.au> <5429156.TnbMflxdSq@PointedEars.de> <5umdnQMO8OI36ajSnZ2dnUVZ_oKdnZ2d@westnet.com.au> <1953157.aqSPkdTlGX@PointedEars.de> <6101254.HsSKKp0Gan@PointedEars.de> Supersedes: <1931129.VYsTINlKIu@PointedEars.de> MIME-Version: 1.0 Lines: 44 NNTP-Posting-Date: 11 Feb 2012 15:21:52 CET NNTP-Posting-Host: 9aa4be0c.newsspool2.arcor-online.net X-Trace: DXC=S?H@RSSCnm7RLigj];iP=8A9EHlD;3Yc24Fo<]lROoR18kF Andrew Poulos wrote: >> I think you are misleading me as it doesn't look like there's a better >> way. > > Wrong on both accounts. For crying out loud, a *closely related* question > has been asked (presumably, *again*) on StackOverflow *yesterday*, and I > have commented on the other answers there, eventually referring to > JSX:css.js (which does not consider getPropertyValue() yet – as the > shorthand is optional, and potentially less efficient thanks to > camel-casing –, but soon): > […] >> but that doesn't really resolve the fact getComputedStyle will fail with >> IE 9 and camel-cased CSS properties. > > Wrong (just tested again). getComputedStyle() "fails" with IE > 9(.0.8112.16421 on Windows 7) in *Compatibility* Mode, but not in > Standards Mode, and it "fails" in IE < 9, of course. Well, *partially* wrong. getComputedStyle() does not fail with IE 9 per se. But it does fail even in Standards Mode with camel-cased CSS properties because getPropertyValue() expects the *real* CSS property name. It is specified so in the W3C DOM Level 2 Style Specification: You MUST *only* camel-case the property name (e. g., "marginTop" instead of "margin-top") when you are accessing style object properties: Hence my assumption that the use of getPropertyValue() might turn out to be more efficient than using the optional shorthand with the camel-cased property name, especially as you need to map "float" to "cssFloat" or "styleFloat" aso. PointedEars -- > If you get a bunch of authors […] that state the same "best practices" > in any programming language, then you can bet who is wrong or right... Not with javascript. Nonsense propagates like wildfire in this field. -- Richard Cornford, comp.lang.javascript, 2011-11-14