on most browsers (e.g. Firefox, Opera) getting the computed Style for a element return a nice object of type CSSStyleDeclaration
. On Chrome 28 and PhantomJS 1.9 I get an object that starts with numbered keys listing all the CSS properties, and then the properties (in case of Chrome).
For example, in opera:
In Chrome 28:
and then eventually you get to the useful part:
in PhantomJS 1.9 it's even worse, you get the numbered attributes, and then only two named properties: lenght and cssText.
...
219: 'glyph-orientation-horizontal',
220: 'glyph-orientation-vertical',
221: '-webkit-svg-shadow',
222: 'vector-effect',
length: 223,
cssText: 'background-attachment: scroll; background-clip: border-box; background-color: rgba(0, 0, 0, 0); background-image: none; background-o...
The object returned in all cases should be a
CSSStyleDeclaration
instance (https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration).The object is only supposed to have the number indexed values and a
length
(making it array-like) andcssText
.The Chrome implementation adds the non-standard named attributes. If you want an simple object of the property/value pairs, you can used the
getPropertyValue
method on the instance. e.g (and most of this code is from the example on MDN)