@@ -40,6 +40,19 @@ function splitClasses(classes) {
40
40
return obj ;
41
41
}
42
42
43
+ // if any other type of options value besides an Object value is
44
+ // passed into the $animate.method() animation then this helper code
45
+ // will be run which will ignore it. While this patch is not the
46
+ // greatest solution to this, a lot of existing plugins depend on
47
+ // $animate to either call the callback (< 1.2) or return a promise
48
+ // that can be changed. This helper function ensures that the options
49
+ // are wiped clean incase a callback function is provided.
50
+ function prepareAnimateOptions ( options ) {
51
+ return isObject ( options )
52
+ ? options
53
+ : { } ;
54
+ }
55
+
43
56
var $$CoreAnimateRunnerProvider = function ( ) {
44
57
this . $get = [ '$q' , '$$rAF' , function ( $q , $$rAF ) {
45
58
function AnimateRunner ( ) { }
@@ -420,7 +433,7 @@ var $AnimateProvider = ['$provide', function($provide) {
420
433
after = after && jqLite ( after ) ;
421
434
parent = parent || after . parent ( ) ;
422
435
domInsert ( element , parent , after ) ;
423
- return $$animateQueue . push ( element , 'enter' , options ) ;
436
+ return $$animateQueue . push ( element , 'enter' , prepareAnimateOptions ( options ) ) ;
424
437
} ,
425
438
426
439
/**
@@ -446,7 +459,7 @@ var $AnimateProvider = ['$provide', function($provide) {
446
459
after = after && jqLite ( after ) ;
447
460
parent = parent || after . parent ( ) ;
448
461
domInsert ( element , parent , after ) ;
449
- return $$animateQueue . push ( element , 'move' , options ) ;
462
+ return $$animateQueue . push ( element , 'move' , prepareAnimateOptions ( options ) ) ;
450
463
} ,
451
464
452
465
/**
@@ -463,7 +476,7 @@ var $AnimateProvider = ['$provide', function($provide) {
463
476
* @return {Promise } the animation callback promise
464
477
*/
465
478
leave : function ( element , options ) {
466
- return $$animateQueue . push ( element , 'leave' , options , function ( ) {
479
+ return $$animateQueue . push ( element , 'leave' , prepareAnimateOptions ( options ) , function ( ) {
467
480
element . remove ( ) ;
468
481
} ) ;
469
482
} ,
@@ -487,7 +500,7 @@ var $AnimateProvider = ['$provide', function($provide) {
487
500
* @return {Promise } the animation callback promise
488
501
*/
489
502
addClass : function ( element , className , options ) {
490
- options = options || { } ;
503
+ options = prepareAnimateOptions ( options ) ;
491
504
options . addClass = mergeClasses ( options . addclass , className ) ;
492
505
return $$animateQueue . push ( element , 'addClass' , options ) ;
493
506
} ,
@@ -511,7 +524,7 @@ var $AnimateProvider = ['$provide', function($provide) {
511
524
* @return {Promise } the animation callback promise
512
525
*/
513
526
removeClass : function ( element , className , options ) {
514
- options = options || { } ;
527
+ options = prepareAnimateOptions ( options ) ;
515
528
options . removeClass = mergeClasses ( options . removeClass , className ) ;
516
529
return $$animateQueue . push ( element , 'removeClass' , options ) ;
517
530
} ,
@@ -536,7 +549,7 @@ var $AnimateProvider = ['$provide', function($provide) {
536
549
* @return {Promise } the animation callback promise
537
550
*/
538
551
setClass : function ( element , add , remove , options ) {
539
- options = options || { } ;
552
+ options = prepareAnimateOptions ( options ) ;
540
553
options . addClass = mergeClasses ( options . addClass , add ) ;
541
554
options . removeClass = mergeClasses ( options . removeClass , remove ) ;
542
555
return $$animateQueue . push ( element , 'setClass' , options ) ;
@@ -564,7 +577,7 @@ var $AnimateProvider = ['$provide', function($provide) {
564
577
* @return {Promise } the animation callback promise
565
578
*/
566
579
animate : function ( element , from , to , className , options ) {
567
- options = options || { } ;
580
+ options = prepareAnimateOptions ( options ) ;
568
581
options . from = options . from ? extend ( options . from , from ) : from ;
569
582
options . to = options . to ? extend ( options . to , to ) : to ;
570
583
0 commit comments