diff options
author | Richard Gibson <richard.gibson@gmail.com> | 2013-05-25 10:18:57 -0400 |
---|---|---|
committer | Richard Gibson <richard.gibson@gmail.com> | 2013-05-28 16:49:48 -0400 |
commit | 6fd5e480c1cd3e481e7097763ee281b65bc74306 (patch) | |
tree | d6a4493c4bab9663ed6d7dc8fa5cb07465fd2db8 /test/unit | |
parent | 68c9d0528c43d89cbdab302c68924fb11cd3439c (diff) | |
download | jquery-6fd5e480c1cd3e481e7097763ee281b65bc74306.tar.gz jquery-6fd5e480c1cd3e481e7097763ee281b65bc74306.zip |
Fix #13937: Correctly scope .finish() following multi-element .animate(). Thanks @gnarf37. Close gh-1279.
(cherry picked from commit ae9e05e9f3cb071232b056005755acb5926e403e)
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/effects.js | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/test/unit/effects.js b/test/unit/effects.js index 05f1c017a..4c4e31495 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -2096,21 +2096,47 @@ test( ".finish( \"custom\" ) - custom queue animations", function() { }); test( ".finish() calls finish of custom queue functions", function() { - function queueTester() { - + function queueTester( next, hooks ) { + hooks.stop = function( gotoEnd ) { + inside++; + equal( this, div[0] ); + ok( gotoEnd, "hooks.stop(true) called"); + }; } - var div = jQuery( "<div>" ); + var div = jQuery( "<div>" ), + inside = 0, + outside = 0; - expect( 3 ); + expect( 6 ); queueTester.finish = function() { + outside++; ok( true, "Finish called on custom queue function" ); }; div.queue( queueTester ).queue( queueTester ).queue( queueTester ).finish(); + equal( inside, 1, "1 stop(true) callback" ); + equal( outside, 2, "2 finish callbacks" ); + div.remove(); }); +asyncTest( ".finish() is applied correctly when multiple elements were animated (#13937)", function() { + expect( 3 ); + + var elems = jQuery("<a>0</a><a>1</a><a>2</a>"); + + elems.animate( { opacity: 0 }, 1500 ).animate( { opacity: 1 }, 1500 ); + setTimeout(function() { + elems.eq( 1 ).finish(); + ok( !elems.eq( 1 ).queue().length, "empty queue for .finish()ed element" ); + ok( elems.eq( 0 ).queue().length, "non-empty queue for preceding element" ); + ok( elems.eq( 2 ).queue().length, "non-empty queue for following element" ); + elems.stop( true ); + start(); + }, 100 ); +}); + asyncTest( "slideDown() after stop() (#13483)", 2, function() { var ul = jQuery( "<ul style='height: 100px;display: block'></ul>" ), origHeight = ul.height(); |