From 6aa4095ed62e3e37dae4c39c00fb627a3b282307 Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Tue, 6 Dec 2011 16:44:32 -0500 Subject: [PATCH] Fix #10796. Allow IE<9 to retrieve uncomputed styles. --- src/css.js | 6 +++--- test/unit/css.js | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/css.js b/src/css.js index b07f5316b..810d18178 100644 --- a/src/css.js +++ b/src/css.js @@ -5,7 +5,7 @@ var ralpha = /alpha\([^)]*\)/i, // fixed for IE9, see #8346 rupper = /([A-Z]|^ms)/g, rnumpx = /^-?\d+(?:px)?$/i, - rnum = /^-?\d/, + rnumnopx = /^-?\d+(?!px)[^\d\s]+$/i, rrelNum = /^([\-+])=([\-+.\de]+)/, cssShow = { position: "absolute", visibility: "hidden", display: "block" }, @@ -280,7 +280,7 @@ if ( document.documentElement.currentStyle ) { // Avoid setting ret to empty string here // so we don't default to auto - if ( ret === null && style && (uncomputed = style[ name ]) ) { + if ( ret == null && style && (uncomputed = style[ name ]) ) { ret = uncomputed; } @@ -289,7 +289,7 @@ if ( document.documentElement.currentStyle ) { // 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 - if ( !rnumpx.test( ret ) && rnum.test( ret ) ) { + if ( rnumnopx.test( ret ) ) { // Remember the original values left = style.left; diff --git a/test/unit/css.js b/test/unit/css.js index e72b835ac..67f450408 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -511,6 +511,29 @@ test("can't get css for disconnected in IE<9, see #10254 and #8388", function() equal( div.css( "top" ), "10px", "can't get top in IE<9, see #8388" ); }); +test("can't get background-position in IE<9, see #10796", function() { + var div = jQuery( "
" ).appendTo( "#qunit-fixture" ), + units = [ + "0 0", + "12px 12px", + "13px 12em", + "12em 13px", + "12em center", + "+12em center", + "12.2em center", + "center center", + ], + l = units.length, + i = 0; + + expect( l ); + + for( ; i < l; i++ ) { + div.css( "background-position", units [ i ] ); + ok( div.css( "background-position" ), "can't get background-position in IE<9, see #10796" ); + } +}); + test("Do not append px to 'fill-opacity' #9548", 1, function() { var $div = jQuery("
").appendTo("#qunit-fixture"); -- 2.39.5