@@ -4,6 +4,13 @@ var $animateMinErr = minErr('$animate');
44var ELEMENT_NODE = 1 ;
55var NG_ANIMATE_CLASSNAME = 'ng-animate' ;
66
7+
8+ function assertNoCallback ( param ) {
9+ if ( isFunction ( param ) ) {
10+ throw $animateMinErr ( 'nocb' , 'Do not pass a callback to animate methods' ) ;
11+ }
12+ }
13+
714function mergeClasses ( a , b ) {
815 if ( ! a && ! b ) return '' ;
916 if ( ! a ) return b ;
@@ -416,6 +423,7 @@ var $AnimateProvider = ['$provide', function($provide) {
416423 * @return {Promise } the animation callback promise
417424 */
418425 enter : function ( element , parent , after , options ) {
426+ assertNoCallback ( options ) ;
419427 parent = parent || after . parent ( ) ;
420428 domInsert ( element , parent , after ) ;
421429 return $$animateQueue . push ( element , 'enter' , options ) ;
@@ -440,6 +448,7 @@ var $AnimateProvider = ['$provide', function($provide) {
440448 * @return {Promise } the animation callback promise
441449 */
442450 move : function ( element , parent , after , options ) {
451+ assertNoCallback ( options ) ;
443452 parent = parent || after . parent ( ) ;
444453 domInsert ( element , parent , after ) ;
445454 return $$animateQueue . push ( element , 'move' , options ) ;
@@ -459,6 +468,7 @@ var $AnimateProvider = ['$provide', function($provide) {
459468 * @return {Promise } the animation callback promise
460469 */
461470 leave : function ( element , options ) {
471+ assertNoCallback ( options ) ;
462472 return $$animateQueue . push ( element , 'leave' , options , function ( ) {
463473 element . remove ( ) ;
464474 } ) ;
@@ -483,6 +493,7 @@ var $AnimateProvider = ['$provide', function($provide) {
483493 * @return {Promise } the animation callback promise
484494 */
485495 addClass : function ( element , className , options ) {
496+ assertNoCallback ( options ) ;
486497 options = options || { } ;
487498 options . addClass = mergeClasses ( options . addclass , className ) ;
488499 return $$animateQueue . push ( element , 'addClass' , options ) ;
@@ -507,6 +518,7 @@ var $AnimateProvider = ['$provide', function($provide) {
507518 * @return {Promise } the animation callback promise
508519 */
509520 removeClass : function ( element , className , options ) {
521+ assertNoCallback ( options ) ;
510522 options = options || { } ;
511523 options . removeClass = mergeClasses ( options . removeClass , className ) ;
512524 return $$animateQueue . push ( element , 'removeClass' , options ) ;
@@ -532,6 +544,7 @@ var $AnimateProvider = ['$provide', function($provide) {
532544 * @return {Promise } the animation callback promise
533545 */
534546 setClass : function ( element , add , remove , options ) {
547+ assertNoCallback ( options ) ;
535548 options = options || { } ;
536549 options . addClass = mergeClasses ( options . addClass , add ) ;
537550 options . removeClass = mergeClasses ( options . removeClass , remove ) ;
@@ -560,6 +573,7 @@ var $AnimateProvider = ['$provide', function($provide) {
560573 * @return {Promise } the animation callback promise
561574 */
562575 animate : function ( element , from , to , className , options ) {
576+ assertNoCallback ( options ) ;
563577 options = options || { } ;
564578 options . from = options . from ? extend ( options . from , from ) : from ;
565579 options . to = options . to ? extend ( options . to , to ) : to ;
0 commit comments