X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fcss.js;h=1e3f6c1666f8af71613c848033eb6f6aff49ee09;hb=53697d10efc25ff4fe2bfdd049b4967b7ab507e6;hp=369485e4768e54cd7dcc28148d7c19e11d64aad9;hpb=3394d32ea75cffb8c8c386d607823cae878b9145;p=jquery.git diff --git a/src/css.js b/src/css.js index 369485e..1e3f6c1 100644 --- a/src/css.js +++ b/src/css.js @@ -179,7 +179,7 @@ jQuery.each(["height", "width"], function( i, name ) { if ( val != null ) { // Should return "auto" instead of 0, use 0 for // temporary backwards-compat - return val === "" ? "0px" : val; + return val === "" || val === "auto" ? "0px" : val; } } @@ -188,7 +188,7 @@ jQuery.each(["height", "width"], function( i, name ) { // Should return "auto" instead of 0, use 0 for // temporary backwards-compat - return val === "" ? "0px" : val; + return val === "" || val === "auto" ? "0px" : val; } return typeof val === "string" ? val : val + "px"; @@ -240,6 +240,25 @@ if ( !jQuery.support.opacity ) { }; } +jQuery(function() { + // This hook cannot be added until DOM ready because the support test + // for it is not run until after DOM ready + if ( !jQuery.support.reliableMarginRight ) { + jQuery.cssHooks.marginRight = { + get: function( elem, computed ) { + // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right + // Work around by temporarily setting element display to inline-block + var ret = "0px", + display = elem.style.display; + elem.style.display = "inline-block"; + ret = getComputedStyle( elem, "margin-right", "margin-right" ); + elem.style.display = display; + return ret; + } + }; + } +}); + if ( document.defaultView && document.defaultView.getComputedStyle ) { getComputedStyle = function( elem, newName, name ) { var ret, defaultView, computedStyle; @@ -263,8 +282,9 @@ if ( document.defaultView && document.defaultView.getComputedStyle ) { if ( document.documentElement.currentStyle ) { currentStyle = function( elem, name ) { - var left, rsLeft, + var left, ret = elem.currentStyle && elem.currentStyle[ name ], + rsLeft = elem.runtimeStyle && elem.runtimeStyle[ name ], style = elem.style; // From the awesome hack by Dean Edwards @@ -275,16 +295,19 @@ if ( document.documentElement.currentStyle ) { if ( !rnumpx.test( ret ) && rnum.test( ret ) ) { // Remember the original values left = style.left; - rsLeft = elem.runtimeStyle.left; // Put in the new values to get a computed value out - elem.runtimeStyle.left = elem.currentStyle.left; + if ( rsLeft ) { + elem.runtimeStyle.left = elem.currentStyle.left; + } style.left = name === "fontSize" ? "1em" : (ret || 0); ret = style.pixelLeft + "px"; // Revert the changed values style.left = left; - elem.runtimeStyle.left = rsLeft; + if ( rsLeft ) { + elem.runtimeStyle.left = rsLeft; + } } return ret === "" ? "auto" : ret;