From ae707f4475fbfd7d9f4b2e26d245b42f9c0d2dae Mon Sep 17 00:00:00 2001 From: Tobie Langel Date: Wed, 3 Sep 2008 18:27:04 -0700 Subject: [PATCH] Fix an issue where Element#getStyle('height') returns null if the height is set to "auto." --- CHANGELOG | 2 ++ src/dom.js | 2 +- test/unit/dom_test.js | 4 ++++ test/unit/fixtures/dom.html | 3 ++- 4 files changed, 9 insertions(+), 2 deletions(-) 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