X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fcss.js;h=a6e2bb6143613a6d187a58c7f803d7beacff5afe;hb=a8fa5f2ec1030bceb9a65d0237f0c92ae4e014dd;hp=4665fa7cbbe671b8c34fca4143fe21aa2971f5b8;hpb=fb48ae8e6cca25fd29ef2b1eb23e9efa7b0eef7c;p=jquery.git diff --git a/src/css.js b/src/css.js index 4665fa7..a6e2bb6 100644 --- a/src/css.js +++ b/src/css.js @@ -12,9 +12,6 @@ var ralpha = /alpha\([^)]*\)/i, cssHeight = [ "Top", "Bottom" ], curCSS, - getComputedStyle, - currentStyle, - fcamelCase = function( all, letter ) { return letter.toUpperCase(); }; @@ -172,18 +169,19 @@ jQuery.each(["height", "width"], function( i, name ) { if ( val <= 0 ) { val = curCSS( elem, name, name ); - if ( val === "0px" && currentStyle ) { - val = currentStyle( 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 ) { val = elem.style[ name ]; - return val === "" ? "auto" : val; + + // 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"; @@ -236,7 +234,7 @@ if ( !jQuery.support.opacity ) { } if ( document.defaultView && document.defaultView.getComputedStyle ) { - getComputedStyle = function( elem, newName, name ) { + curCSS = function( elem, newName, name ) { var ret, defaultView, computedStyle; name = name.replace( rupper, "-$1" ).toLowerCase(); @@ -254,10 +252,8 @@ if ( document.defaultView && document.defaultView.getComputedStyle ) { return ret; }; -} - -if ( document.documentElement.currentStyle ) { - currentStyle = function( elem, name ) { +} else if ( document.documentElement.currentStyle ) { + curCSS = function( elem, name ) { var left, rsLeft, ret = elem.currentStyle && elem.currentStyle[ name ], style = elem.style; @@ -286,8 +282,6 @@ if ( document.documentElement.currentStyle ) { }; } -curCSS = getComputedStyle || currentStyle; - function getWH( elem, name, extra ) { var which = name === "width" ? cssWidth : cssHeight, val = name === "width" ? elem.offsetWidth : elem.offsetHeight;