aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjeresig <jeresig@gmail.com>2010-11-01 19:04:59 -0400
committerjeresig <jeresig@gmail.com>2010-11-01 19:04:59 -0400
commit9d1bfeb7ffe63b5a7488929b7be847bc1a00f6a6 (patch)
treea6b8215122edd2f73d137ac5c8a551ea588b4794
parente377621eaf85915b8459632cf2565e40e54d6c19 (diff)
downloadjquery-9d1bfeb7ffe63b5a7488929b7be847bc1a00f6a6.tar.gz
jquery-9d1bfeb7ffe63b5a7488929b7be847bc1a00f6a6.zip
Make sure that accessing computed CSS for elements returns 'auto' instead of '' consistently. Fixes #7337.
-rw-r--r--src/css.js9
-rw-r--r--test/unit/css.js4
2 files changed, 7 insertions, 6 deletions
diff --git a/src/css.js b/src/css.js
index 30cecf39d..0998657b0 100644
--- a/src/css.js
+++ b/src/css.js
@@ -173,12 +173,13 @@ jQuery.each(["height", "width"], function( i, name ) {
val = curCSS( elem, name, name );
if ( val != null ) {
- return val === "auto" ? "" : val;
+ return val;
}
}
if ( val < 0 || val == null ) {
- return elem.style[ name ];
+ val = elem.style[ name ];
+ return val === "" ? "auto" : val;
}
return typeof val === "string" ? val : val + "px";
@@ -247,7 +248,7 @@ if ( getComputedStyle ) {
}
}
- return ret;
+ return ret === "" ? "auto" : ret;
};
} else if ( document.documentElement.currentStyle ) {
@@ -274,7 +275,7 @@ if ( getComputedStyle ) {
elem.runtimeStyle.left = rsLeft;
}
- return ret;
+ return ret === "" ? "auto" : ret;
};
}
diff --git a/test/unit/css.js b/test/unit/css.js
index 4ec7c60ae..71f883508 100644
--- a/test/unit/css.js
+++ b/test/unit/css.js
@@ -13,8 +13,8 @@ test("css(String|Hash)", function() {
var div = jQuery( "<div>" );
- equals( div.css("width"), "", "Width on disconnected node." );
- equals( div.css("height"), "", "Height on disconnected node." );
+ equals( div.css("width"), "auto", "Width on disconnected node." );
+ equals( div.css("height"), "auto", "Height on disconnected node." );
div.css({ width: 4, height: 4 });