Skip to content

Commit

Permalink
Landing pull request 562. Make sure runtimeStyle isn't affected by di…
Browse files Browse the repository at this point in the history
…mensions. Fixes #9233.

More Details:
 - #562
 - http://bugs.jquery.com/ticket/9233
  • Loading branch information
mikesherov authored and timmywil committed Oct 28, 2011
1 parent 5c0c863 commit fa0e801
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/css.js
Expand Up @@ -285,9 +285,8 @@ if ( document.defaultView && document.defaultView.getComputedStyle ) {


if ( document.documentElement.currentStyle ) { if ( document.documentElement.currentStyle ) {
currentStyle = function( elem, name ) { currentStyle = function( elem, name ) {
var left, var left, rsLeft,
ret = elem.currentStyle && elem.currentStyle[ name ], ret = elem.currentStyle && elem.currentStyle[ name ],
rsLeft = elem.runtimeStyle && elem.runtimeStyle[ name ],
style = elem.style; style = elem.style;


if ( ret === null && style ) { if ( ret === null && style ) {
Expand All @@ -300,8 +299,10 @@ if ( document.documentElement.currentStyle ) {
// If we're not dealing with a regular pixel number // If we're not dealing with a regular pixel number
// but a number that has a weird ending, we need to convert it to pixels // but a number that has a weird ending, we need to convert it to pixels
if ( !rnumpx.test( ret ) && rnum.test( ret ) ) { if ( !rnumpx.test( ret ) && rnum.test( ret ) ) {

// Remember the original values // Remember the original values
left = style.left; left = style.left;
rsLeft = elem.runtimeStyle && elem.runtimeStyle.left;


// Put in the new values to get a computed value out // Put in the new values to get a computed value out
if ( rsLeft ) { if ( rsLeft ) {
Expand Down
23 changes: 23 additions & 0 deletions test/unit/dimensions.js
Expand Up @@ -245,6 +245,29 @@ test("child of a hidden elem has accurate inner/outer/Width()/Height() see #944
$divNormal.remove(); $divNormal.remove();
}); });


test("getting dimensions shouldnt modify runtimeStyle see #9233", function() {
expect( 1 );

var $div = jQuery( "<div>" ).appendTo( "#qunit-fixture" ),
div = $div.get( 0 ),
runtimeStyle = div.runtimeStyle;

if ( runtimeStyle ) {
div.runtimeStyle.marginLeft = "12em";
div.runtimeStyle.left = "11em";
}

$div.outerWidth( true );

if ( runtimeStyle ) {
equal( div.runtimeStyle.left, "11em", "getting dimensions modifies runtimeStyle, see #9233" );
} else {
ok( true, "this browser doesnt support runtimeStyle, see #9233" );
}

$div.remove();
});

test("outerHeight()", function() { test("outerHeight()", function() {
expect(11); expect(11);


Expand Down

0 comments on commit fa0e801

Please sign in to comment.