Moved jQuery.ajax.prefilter and jQuery.ajax.transport to jQuery.ajaxPrefilter and...
[jquery.git] / src / css.js
index 88c4ffa..a6e2bb6 100644 (file)
@@ -12,9 +12,6 @@ var ralpha = /alpha\([^)]*\)/i,
        cssHeight = [ "Top", "Bottom" ],
        curCSS,
 
-       // cache check for defaultView.getComputedStyle
-       getComputedStyle = document.defaultView && document.defaultView.getComputedStyle,
-
        fcamelCase = function( all, letter ) {
                return letter.toUpperCase();
        };
@@ -169,20 +166,22 @@ jQuery.each(["height", "width"], function( i, name ) {
                                        });
                                }
 
-                               if ( val < 0 ) {
-                                       return elem.style[ name ] || "0px";
-                               }
-
-                               if ( val === 0 ) {
+                               if ( val <= 0 ) {
                                        val = curCSS( elem, name, name );
 
                                        if ( val != null ) {
-                                               return val;
+                                               // Should return "auto" instead of 0, use 0 for
+                                               // temporary backwards-compat
+                                               return val === "" || val === "auto" ? "0px" : val;
                                        }
                                }
 
                                if ( val < 0 || val == null ) {
-                                       return elem.style[ name ];
+                                       val = elem.style[ name ];
+
+                                       // Should return "auto" instead of 0, use 0 for
+                                       // temporary backwards-compat
+                                       return val === "" || val === "auto" ? "0px" : val;
                                }
 
                                return typeof val === "string" ? val : val + "px";
@@ -234,7 +233,7 @@ if ( !jQuery.support.opacity ) {
        };
 }
 
-if ( getComputedStyle ) {
+if ( document.defaultView && document.defaultView.getComputedStyle ) {
        curCSS = function( elem, newName, name ) {
                var ret, defaultView, computedStyle;
 
@@ -253,10 +252,11 @@ if ( getComputedStyle ) {
 
                return ret;
        };
-
 } else if ( document.documentElement.currentStyle ) {
        curCSS = function( elem, name ) {
-               var left, rsLeft, ret = elem.currentStyle && elem.currentStyle[ name ], style = elem.style;
+               var left, rsLeft,
+                       ret = elem.currentStyle && elem.currentStyle[ name ],
+                       style = elem.style;
 
                // From the awesome hack by Dean Edwards
                // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
@@ -278,7 +278,7 @@ if ( getComputedStyle ) {
                        elem.runtimeStyle.left = rsLeft;
                }
 
-               return ret;
+               return ret === "" ? "auto" : ret;
        };
 }
 
@@ -308,7 +308,8 @@ function getWH( elem, name, extra ) {
 
 if ( jQuery.expr && jQuery.expr.filters ) {
        jQuery.expr.filters.hidden = function( elem ) {
-               var width = elem.offsetWidth, height = elem.offsetHeight;
+               var width = elem.offsetWidth,
+                       height = elem.offsetHeight;
 
                return (width === 0 && height === 0) || (!jQuery.support.reliableHiddenOffsets && (elem.style.display || jQuery.css( elem, "display" )) === "none");
        };