window.getComputedStyle needs help.
Reported by nickg | April 15th, 2010 @ 04:32 AM
While investigating a ecma5 strict mode error, I raw into
- getComputedStyle : function(element, pseudoElement){
- if(CSS2Properties){
- return element?
- element.style:new CSS2Properties({cssText:""});
- }
since it could return "undefined" sometimes. Turns out "new CSS2Properties({cssText:""});" actually would explode since it's ctor wants other input. So the if statement was actually bogus.
I replaced it with
+ /**
+ * getComputedStyle
+ *
+ * Firefox 3.6:
+ * - Requires both elements to be present else an
+ * exception is thrown.
+ * - Returns a 'ComputedCSSStyleDeclaration' object.
+ * while a raw element.style returns a 'CSSStyleDeclaration' object.
+ * - Bogus input also throws exception
+ *
+ * Safari 4:
+ * - Requires one argument (second can be MIA)
+ * - Returns a CSSStyleDeclaration object
+ * - if bad imput, returns null
+ *
+ * getComputedStyle should really be an "add on" from the css
+ * modules. Unfortunately, 'window' comes way after the 'css'
+ * so css can't add it.
+ */
+ getComputedStyle: function(element, pseudoElement) {
+ return element.style;
},
and added stubs for specs/window/specs.js
and fixed
the boot.js
to include css.dist
.
I leave it to the next guy to hack on! (unless I bump into a page that needs this more fleshed out).
--nickg
No comments found
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
a javascript browser environment