By Nietecht
Wednesday, 19. March 2008, 01:30:11
Opera's 'getCalculatedStyle' methods buggy? (width specifically)
Not sure this is the right place, but...I'm trying to work with getting the 'calculated style' of elements.
I'm not sure what the 'standard' is supposed to be, just that Firefox/Safari work with "defaultView" and "getComputedStyle", whereas Internet Explorer works with "currentStyle".
I've noticed Opera seems to support both, but both ways are different than how the other mentioned browsers implemented it.
Especially the width and height property are different.
Assume a div element with style "width: 200px; padding: 10px; border-width: 1px;".
FF and IE, using their specific methods, I get "200px" as the width for that element.
In Opera, using IE's method also returns "200px", but "222px" when using FF's method, the same as offsetWidth (including padding and borders).
This is still workable, choosing for IE's method as default, but it becomes inconsistent when the element is hidden using display: none.
When an element has display: none, using IE's method, the calculated width will return "0px" (unlike IE), whereas the calculated height will still return what it would have when not hidden, as in IE.
Width and height will also return "0px" using FF's method (unlike FF) when hidden.
This forces me to substract left/right paddings and borders from the offsetWidth just for Opera when the element is hidden, that can't be right.
Is this a bug or am doing it wrong?
