@@ -4,6 +4,13 @@ var $animateMinErr = minErr('$animate');
4
4
var ELEMENT_NODE = 1 ;
5
5
var NG_ANIMATE_CLASSNAME = 'ng-animate' ;
6
6
7
+
8
+ function assertNoCallback ( param ) {
9
+ if ( isFunction ( param ) ) {
10
+ throw $animateMinErr ( 'nocb' , 'Do not pass a callback to animate methods' ) ;
11
+ }
12
+ }
13
+
7
14
function mergeClasses ( a , b ) {
8
15
if ( ! a && ! b ) return '' ;
9
16
if ( ! a ) return b ;
@@ -416,6 +423,7 @@ var $AnimateProvider = ['$provide', function($provide) {
416
423
* @return {Promise } the animation callback promise
417
424
*/
418
425
enter : function ( element , parent , after , options ) {
426
+ assertNoCallback ( options ) ;
419
427
parent = parent || after . parent ( ) ;
420
428
domInsert ( element , parent , after ) ;
421
429
return $$animateQueue . push ( element , 'enter' , options ) ;
@@ -440,6 +448,7 @@ var $AnimateProvider = ['$provide', function($provide) {
440
448
* @return {Promise } the animation callback promise
441
449
*/
442
450
move : function ( element , parent , after , options ) {
451
+ assertNoCallback ( options ) ;
443
452
parent = parent || after . parent ( ) ;
444
453
domInsert ( element , parent , after ) ;
445
454
return $$animateQueue . push ( element , 'move' , options ) ;
@@ -459,6 +468,7 @@ var $AnimateProvider = ['$provide', function($provide) {
459
468
* @return {Promise } the animation callback promise
460
469
*/
461
470
leave : function ( element , options ) {
471
+ assertNoCallback ( options ) ;
462
472
return $$animateQueue . push ( element , 'leave' , options , function ( ) {
463
473
element . remove ( ) ;
464
474
} ) ;
@@ -483,6 +493,7 @@ var $AnimateProvider = ['$provide', function($provide) {
483
493
* @return {Promise } the animation callback promise
484
494
*/
485
495
addClass : function ( element , className , options ) {
496
+ assertNoCallback ( options ) ;
486
497
options = options || { } ;
487
498
options . addClass = mergeClasses ( options . addclass , className ) ;
488
499
return $$animateQueue . push ( element , 'addClass' , options ) ;
@@ -507,6 +518,7 @@ var $AnimateProvider = ['$provide', function($provide) {
507
518
* @return {Promise } the animation callback promise
508
519
*/
509
520
removeClass : function ( element , className , options ) {
521
+ assertNoCallback ( options ) ;
510
522
options = options || { } ;
511
523
options . removeClass = mergeClasses ( options . removeClass , className ) ;
512
524
return $$animateQueue . push ( element , 'removeClass' , options ) ;
@@ -532,6 +544,7 @@ var $AnimateProvider = ['$provide', function($provide) {
532
544
* @return {Promise } the animation callback promise
533
545
*/
534
546
setClass : function ( element , add , remove , options ) {
547
+ assertNoCallback ( options ) ;
535
548
options = options || { } ;
536
549
options . addClass = mergeClasses ( options . addClass , add ) ;
537
550
options . removeClass = mergeClasses ( options . removeClass , remove ) ;
@@ -560,6 +573,7 @@ var $AnimateProvider = ['$provide', function($provide) {
560
573
* @return {Promise } the animation callback promise
561
574
*/
562
575
animate : function ( element , from , to , className , options ) {
576
+ assertNoCallback ( options ) ;
563
577
options = options || { } ;
564
578
options . from = options . from ? extend ( options . from , from ) : from ;
565
579
options . to = options . to ? extend ( options . to , to ) : to ;
0 commit comments