aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Gaidarenko <markelog@gmail.com>2015-12-22 17:27:38 +0300
committerOleg Gaidarenko <markelog@gmail.com>2015-12-22 17:27:38 +0300
commit7c0982029f6a013e038fc1a49a483c6f8a24c460 (patch)
tree9d397aaf1a8c356a05b67ab8314747dd8d7ed705
parente0d8fc9232c3ade0059590cba3be020649b90f1b (diff)
downloadjquery-7c0982029f6a013e038fc1a49a483c6f8a24c460.tar.gz
jquery-7c0982029f6a013e038fc1a49a483c6f8a24c460.zip
Revert "CSS: simplify hack of css getter for the computed values"
This reverts commit dac716ca65a83bab2449ffa35c43b4b52e26a0c1.
-rw-r--r--src/css/curCSS.js12
-rw-r--r--test/data/testsuite.css5
-rw-r--r--test/unit/css.js15
3 files changed, 12 insertions, 20 deletions
diff --git a/src/css/curCSS.js b/src/css/curCSS.js
index 8acf49038..078cff6e1 100644
--- a/src/css/curCSS.js
+++ b/src/css/curCSS.js
@@ -76,7 +76,7 @@ if ( window.getComputedStyle ) {
};
curCSS = function( elem, name, computed ) {
- var left, ret,
+ var left, rs, rsLeft, ret,
style = elem.style;
computed = computed || getStyles( elem );
@@ -88,7 +88,7 @@ if ( window.getComputedStyle ) {
ret = style[ name ];
}
- // Simplified hack by Dean Edwards
+ // From the awesome hack by Dean Edwards
// http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
// If we're not dealing with a regular pixel number
@@ -101,13 +101,21 @@ if ( window.getComputedStyle ) {
// Remember the original values
left = style.left;
+ rs = elem.runtimeStyle;
+ rsLeft = rs && rs.left;
// Put in the new values to get a computed value out
+ if ( rsLeft ) {
+ rs.left = elem.currentStyle.left;
+ }
style.left = name === "fontSize" ? "1em" : ret;
ret = style.pixelLeft + "px";
// Revert the changed values
style.left = left;
+ if ( rsLeft ) {
+ rs.left = rsLeft;
+ }
}
// Support: IE<9
diff --git a/test/data/testsuite.css b/test/data/testsuite.css
index 9f80473d8..de5f3fb00 100644
--- a/test/data/testsuite.css
+++ b/test/data/testsuite.css
@@ -163,8 +163,3 @@ section { background:#f0f; display:block; }
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
}
-.get-computed-value {
- padding-left: 50%;
- width: 20%;
- font-size: 2em;
-}
diff --git a/test/unit/css.js b/test/unit/css.js
index b15f2c76d..79dfbe903 100644
--- a/test/unit/css.js
+++ b/test/unit/css.js
@@ -122,19 +122,8 @@ QUnit.test( "css(String|Hash)", function( assert ) {
QUnit.test( "css(String) computed values", function( assert ) {
assert.expect( 3 );
- var div = jQuery( "<div/>" ).addClass( "get-computed-value" ),
- fixture = document.getElementById( "qunit-fixture" );
-
- div.appendTo( fixture );
- assert.strictEqual( div.css( "padding-left" ), "500px", "should get computed value for padding-left property" );
- assert.strictEqual( div.css( "width" ), "200px", "should get computed value for width property" );
- assert.strictEqual( div.css( "font-size" ), "32px", "should get computed value for font-size property" );
-} );
-
-QUnit.test( "css() explicit and relative values", function( assert ) {
- assert.expect( 29 );
-
- var $elem = jQuery( "#nothiddendiv" );
+test( "css() explicit and relative values", 29, function() {
+ var $elem = jQuery("#nothiddendiv");
$elem.css( { "width": 1, "height": 1, "paddingLeft": "1px", "opacity": 1 } );
assert.equal( $elem.css( "width" ), "1px", "Initial css set or width/height works (hash)" );