Fix an issue where Element#getStyle('height') returns null if the height is set to "auto."

This commit is contained in:
Tobie Langel 2008-09-03 18:27:04 -07:00
parent 919b952ec3
commit ae707f4475
4 changed files with 9 additions and 2 deletions

View File

@ -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)

View File

@ -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;
}

View File

@ -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() {

View File

@ -274,4 +274,5 @@
<div id="anonymous_element_3"></div>
</div>
<div id='elementToViewportDimensions' style='display: none'></div>
<div id='elementToViewportDimensions' style='display: none'></div>
<div id="auto_dimensions" style="height:auto"></div>