]> source.dussan.org Git - jquery-ui.git/commitdiff
Effect: Make .transfer() callback optional 1545/head
authorJörn Zaefferer <joern.zaefferer@gmail.com>
Wed, 22 Apr 2015 13:50:43 +0000 (15:50 +0200)
committerJörn Zaefferer <joern.zaefferer@gmail.com>
Fri, 24 Apr 2015 13:13:07 +0000 (15:13 +0200)
Adds two tests to at least check that no exception is thrown.

Fixes #12223
Closes gh-1545

tests/unit/effects/core.js
ui/effect.js

index 76fcaa06221e8e4ac4105c2286f25927b1c944a7..db83ca0933acf55fb48854a2f00c4317b3f25939 100644 (file)
@@ -258,6 +258,32 @@ test( "createPlaceholder: preserves layout affecting properties", function() {
        deepEqual( before.outerHeight, placeholder.outerHeight( true ), "height preserved" );
 });
 
+module( "transfer" );
+
+asyncTest( "transfer() without callback", function() {
+       expect( 0 );
+
+       // Verify that the effect works without a callback
+       $( "#elem" ).transfer( {
+               to: ".animateClass",
+               duration: 1
+       } );
+       setTimeout( function() {
+               start();
+       }, 25 );
+} );
+
+asyncTest( "transfer() with callback", function() {
+       expect( 1 );
+       $( "#elem" ).transfer( {
+               to: ".animateClass",
+               duration: 1
+       }, function() {
+               ok( true, "callback invoked" );
+               start();
+       } );
+} );
+
 $.each( $.effects.effect, function( effect ) {
        module( "effects." + effect );
 
index cc9a91045c4147050a01b51f59e2c04f3f7f0de4..a946c6e8b3074ad2a7b517a753af749e14d95577 100644 (file)
@@ -1505,7 +1505,9 @@ $.fn.extend({
                                })
                                .animate( animation, options.duration, options.easing, function() {
                                        transfer.remove();
-                                       done();
+                                       if ( $.isFunction( done ) ) {
+                                               done();
+                                       }
                                });
        }
 });