]> source.dussan.org Git - jquery.git/commitdiff
Make sure that accessing computed CSS for elements returns 'auto' instead of '' consi...
authorjeresig <jeresig@gmail.com>
Mon, 1 Nov 2010 23:04:59 +0000 (19:04 -0400)
committerjeresig <jeresig@gmail.com>
Mon, 1 Nov 2010 23:04:59 +0000 (19:04 -0400)
src/css.js
test/unit/css.js

index 30cecf39d42f54c3a18d9967600a7098b4e35cc9..0998657b047f94ed8075699c60bc9d00374bce48 100644 (file)
@@ -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;
        };
 }
 
index 4ec7c60ae8ba8e7f91688ef0c952ca0ffda4b8ab..71f883508da133e709086afa859db286b85a21b1 100644 (file)
@@ -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 });