diff --git a/CHANGELOG b/CHANGELOG index ccf7b6a..4514274 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Fix an issue where Element#getStyle('height') returns null if the height is set to "auto." (kangax, jddalton) + * Add unit tests for Element#descendantOf. (jddalton) * Form#serializeElements should not serialize file inputs. (kangax, Lonesome Boy) diff --git a/src/dom.js b/src/dom.js index d5df211..df0162b 100644 --- a/src/dom.js +++ b/src/dom.js @@ -387,7 +387,7 @@ Element.Methods = { element = $(element); style = style == 'float' ? 'cssFloat' : style.camelize(); var value = element.style[style]; - if (!value) { + if (!value || value == 'auto') { var css = document.defaultView.getComputedStyle(element, null); value = css ? css[style] : null; } diff --git a/test/unit/dom_test.js b/test/unit/dom_test.js index 4776924..6aedb61 100644 --- a/test/unit/dom_test.js +++ b/test/unit/dom_test.js @@ -891,6 +891,10 @@ new Test.Unit.Runner({ this.assertEqual("14px", $('style_test_dimensions').getStyle('width')); this.assertEqual("17px", $('style_test_dimensions').getStyle('height')); } + + // height/width could always be calculated if it's set to "auto" (Firefox) + this.assertNotNull($('auto_dimensions').getStyle('height')); + this.assertNotNull($('auto_dimensions').getStyle('width')); }, testElementGetOpacity: function() { diff --git a/test/unit/fixtures/dom.html b/test/unit/fixtures/dom.html index a58a20d..61c70da 100644 --- a/test/unit/fixtures/dom.html +++ b/test/unit/fixtures/dom.html @@ -274,4 +274,5 @@
- \ No newline at end of file + + \ No newline at end of file