From: jeresig Date: Mon, 17 Jan 2011 20:50:20 +0000 (-0500) Subject: Merge branch '7608' of https://github.com/rwldrn/jquery into rwldrn-7608 X-Git-Url: http://git.asbjorn.it/?a=commitdiff_plain;h=f01ef93aab1d2e90efbcacc71b01180f7f33656b;hp=987c44bee48557f693a59bc7ecc1bbe1718c428c;p=jquery.git Merge branch '7608' of https://github.com/rwldrn/jquery into rwldrn-7608 --- diff --git a/src/css.js b/src/css.js index 8a83c60..19c6342 100644 --- a/src/css.js +++ b/src/css.js @@ -263,8 +263,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 +276,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; diff --git a/test/unit/css.js b/test/unit/css.js index fbbf937..3e65b51 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -320,3 +320,25 @@ test(":visible selector works properly on children with a hidden parent (bug #45 jQuery('#table').css('display', 'none').html('cellcell'); equals(jQuery('#table td:visible').length, 0, "hidden cell children not perceived as visible"); }); + +test("internal ref to elem.runtimeStyle (bug #7608)", function () { + expect(1); + + var result = true, + val = 10; + + jQuery('
' + + '
 
').appendTo("#main"); + + try { + // the bug is located within src/css.js + jQuery("#bug7608 #test").animate( { width: val }, 1000); + + } catch (e) { + result = false; + } + + ok( result, "elem.runtimeStyle does not throw exception" ); + + jQuery("#bug7608").remove(); +});