X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fcss.js;h=a6e2bb6143613a6d187a58c7f803d7beacff5afe;hb=a8fa5f2ec1030bceb9a65d0237f0c92ae4e014dd;hp=30cecf39d42f54c3a18d9967600a7098b4e35cc9;hpb=53396b879bd29c090824da182e3cf69158829f82;p=jquery.git diff --git a/src/css.js b/src/css.js index 30cecf3..a6e2bb6 100644 --- a/src/css.js +++ b/src/css.js @@ -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(); }; @@ -173,12 +170,18 @@ jQuery.each(["height", "width"], function( i, name ) { val = curCSS( elem, name, name ); if ( val != null ) { - return val === "auto" ? "" : 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"; @@ -230,7 +233,7 @@ if ( !jQuery.support.opacity ) { }; } -if ( getComputedStyle ) { +if ( document.defaultView && document.defaultView.getComputedStyle ) { curCSS = function( elem, newName, name ) { var ret, defaultView, computedStyle; @@ -249,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 @@ -274,7 +278,7 @@ if ( getComputedStyle ) { elem.runtimeStyle.left = rsLeft; } - return ret; + return ret === "" ? "auto" : ret; }; } @@ -304,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"); };