From dd2efb44f410fbcfd54731286ccd259a29eee0bf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gerg=C5=91=20Tisza?= Date: Thu, 27 Feb 2014 00:26:50 +0000 Subject: [PATCH] Fix jQuery compatibility issues in jquery.color.js Fix two issues which caused jquery.color to be incompatible with the currently used jQuery version: * The $.fx.step hook in jquery.color.js relied on fx.state which is not provided by current jQuery. This commit replaces it with a manual flag (the same logic is used in the official jquery.color plugin). * It used $.curCSS which has been replaced by $.css. Change-Id: I3aa0d912b21da40167124c646fb1b35beb277a33 --- resources/jquery/jquery.color.js | 5 +++-- tests/qunit/QUnitTestResources.php | 2 ++ .../suites/resources/jquery/jquery.color.test.js | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 tests/qunit/suites/resources/jquery/jquery.color.test.js diff --git a/resources/jquery/jquery.color.js b/resources/jquery/jquery.color.js index 8bc45c97c8..04f8047b8e 100644 --- a/resources/jquery/jquery.color.js +++ b/resources/jquery/jquery.color.js @@ -14,7 +14,7 @@ var color; do { - color = $.curCSS( elem, attr ); + color = $.css( elem, attr ); // Keep going until we find an element that has color, or we hit the body if ( color !== '' && color !== 'transparent' || $.nodeName( elem, 'body' ) ) { @@ -38,9 +38,10 @@ 'outlineColor' ], function ( i, attr ) { $.fx.step[attr] = function ( fx ) { - if ( fx.state === 0 ) { + if ( !fx.colorInit ) { fx.start = getColor( fx.elem, attr ); fx.end = $.colorUtil.getRGB( fx.end ); + fx.colorInit = true; } fx.elem.style[attr] = 'rgb(' + [ diff --git a/tests/qunit/QUnitTestResources.php b/tests/qunit/QUnitTestResources.php index 63f610fe55..f6748198e6 100644 --- a/tests/qunit/QUnitTestResources.php +++ b/tests/qunit/QUnitTestResources.php @@ -42,6 +42,7 @@ return array( 'tests/qunit/suites/resources/jquery/jquery.byteLength.test.js', 'tests/qunit/suites/resources/jquery/jquery.byteLimit.test.js', 'tests/qunit/suites/resources/jquery/jquery.client.test.js', + 'tests/qunit/suites/resources/jquery/jquery.color.test.js', 'tests/qunit/suites/resources/jquery/jquery.colorUtil.test.js', 'tests/qunit/suites/resources/jquery/jquery.delayedBind.test.js', 'tests/qunit/suites/resources/jquery/jquery.getAttrs.test.js', @@ -74,6 +75,7 @@ return array( 'jquery.byteLength', 'jquery.byteLimit', 'jquery.client', + 'jquery.color', 'jquery.colorUtil', 'jquery.delayedBind', 'jquery.getAttrs', diff --git a/tests/qunit/suites/resources/jquery/jquery.color.test.js b/tests/qunit/suites/resources/jquery/jquery.color.test.js new file mode 100644 index 0000000000..b644a3ceba --- /dev/null +++ b/tests/qunit/suites/resources/jquery/jquery.color.test.js @@ -0,0 +1,15 @@ +( function ( $ ) { + QUnit.module( 'jquery.color', QUnit.newMwEnvironment() ); + + QUnit.asyncTest( 'animate', 3, function ( assert ) { + var $canvas = $( '
' ).css( 'background-color', '#fff' ); + + $canvas.animate( { backgroundColor: '#000' }, 4 ).promise().then( function() { + var endColors = $.colorUtil.getRGB( $canvas.css( 'background-color' ) ); + assert.strictEqual( endColors[0], 0 ); + assert.strictEqual( endColors[1], 0 ); + assert.strictEqual( endColors[2], 0 ); + QUnit.start(); + } ); + } ); +}( jQuery ) ); -- 2.20.1