Commit 9d1bfeb7 authored by jeresig's avatar jeresig

Make sure that accessing computed CSS for elements returns 'auto' instead of...

Make sure that accessing computed CSS for elements returns 'auto' instead of '' consistently. Fixes #7337.
parent e377621e
...@@ -173,12 +173,13 @@ jQuery.each(["height", "width"], function( i, name ) { ...@@ -173,12 +173,13 @@ jQuery.each(["height", "width"], function( i, name ) {
val = curCSS( elem, name, name ); val = curCSS( elem, name, name );
if ( val != null ) { if ( val != null ) {
return val === "auto" ? "" : val; return val;
} }
} }
if ( val < 0 || val == null ) { if ( val < 0 || val == null ) {
return elem.style[ name ]; val = elem.style[ name ];
return val === "" ? "auto" : val;
} }
return typeof val === "string" ? val : val + "px"; return typeof val === "string" ? val : val + "px";
...@@ -247,7 +248,7 @@ if ( getComputedStyle ) { ...@@ -247,7 +248,7 @@ if ( getComputedStyle ) {
} }
} }
return ret; return ret === "" ? "auto" : ret;
}; };
} else if ( document.documentElement.currentStyle ) { } else if ( document.documentElement.currentStyle ) {
...@@ -274,7 +275,7 @@ if ( getComputedStyle ) { ...@@ -274,7 +275,7 @@ if ( getComputedStyle ) {
elem.runtimeStyle.left = rsLeft; elem.runtimeStyle.left = rsLeft;
} }
return ret; return ret === "" ? "auto" : ret;
}; };
} }
......
...@@ -13,8 +13,8 @@ test("css(String|Hash)", function() { ...@@ -13,8 +13,8 @@ test("css(String|Hash)", function() {
var div = jQuery( "<div>" ); var div = jQuery( "<div>" );
equals( div.css("width"), "", "Width on disconnected node." ); equals( div.css("width"), "auto", "Width on disconnected node." );
equals( div.css("height"), "", "Height on disconnected node." ); equals( div.css("height"), "auto", "Height on disconnected node." );
div.css({ width: 4, height: 4 }); div.css({ width: 4, height: 4 });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment