@@ -40,6 +40,19 @@ function splitClasses(classes) {
4040 return obj ;
4141}
4242
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+
4356var $$CoreAnimateRunnerProvider = function ( ) {
4457 this . $get = [ '$q' , '$$rAF' , function ( $q , $$rAF ) {
4558 function AnimateRunner ( ) { }
@@ -420,7 +433,7 @@ var $AnimateProvider = ['$provide', function($provide) {
420433 after = after && jqLite ( after ) ;
421434 parent = parent || after . parent ( ) ;
422435 domInsert ( element , parent , after ) ;
423- return $$animateQueue . push ( element , 'enter' , options ) ;
436+ return $$animateQueue . push ( element , 'enter' , prepareAnimateOptions ( options ) ) ;
424437 } ,
425438
426439 /**
@@ -446,7 +459,7 @@ var $AnimateProvider = ['$provide', function($provide) {
446459 after = after && jqLite ( after ) ;
447460 parent = parent || after . parent ( ) ;
448461 domInsert ( element , parent , after ) ;
449- return $$animateQueue . push ( element , 'move' , options ) ;
462+ return $$animateQueue . push ( element , 'move' , prepareAnimateOptions ( options ) ) ;
450463 } ,
451464
452465 /**
@@ -463,7 +476,7 @@ var $AnimateProvider = ['$provide', function($provide) {
463476 * @return {Promise } the animation callback promise
464477 */
465478 leave : function ( element , options ) {
466- return $$animateQueue . push ( element , 'leave' , options , function ( ) {
479+ return $$animateQueue . push ( element , 'leave' , prepareAnimateOptions ( options ) , function ( ) {
467480 element . remove ( ) ;
468481 } ) ;
469482 } ,
@@ -487,7 +500,7 @@ var $AnimateProvider = ['$provide', function($provide) {
487500 * @return {Promise } the animation callback promise
488501 */
489502 addClass : function ( element , className , options ) {
490- options = options || { } ;
503+ options = prepareAnimateOptions ( options ) ;
491504 options . addClass = mergeClasses ( options . addclass , className ) ;
492505 return $$animateQueue . push ( element , 'addClass' , options ) ;
493506 } ,
@@ -511,7 +524,7 @@ var $AnimateProvider = ['$provide', function($provide) {
511524 * @return {Promise } the animation callback promise
512525 */
513526 removeClass : function ( element , className , options ) {
514- options = options || { } ;
527+ options = prepareAnimateOptions ( options ) ;
515528 options . removeClass = mergeClasses ( options . removeClass , className ) ;
516529 return $$animateQueue . push ( element , 'removeClass' , options ) ;
517530 } ,
@@ -536,7 +549,7 @@ var $AnimateProvider = ['$provide', function($provide) {
536549 * @return {Promise } the animation callback promise
537550 */
538551 setClass : function ( element , add , remove , options ) {
539- options = options || { } ;
552+ options = prepareAnimateOptions ( options ) ;
540553 options . addClass = mergeClasses ( options . addClass , add ) ;
541554 options . removeClass = mergeClasses ( options . removeClass , remove ) ;
542555 return $$animateQueue . push ( element , 'setClass' , options ) ;
@@ -564,7 +577,7 @@ var $AnimateProvider = ['$provide', function($provide) {
564577 * @return {Promise } the animation callback promise
565578 */
566579 animate : function ( element , from , to , className , options ) {
567- options = options || { } ;
580+ options = prepareAnimateOptions ( options ) ;
568581 options . from = options . from ? extend ( options . from , from ) : from ;
569582 options . to = options . to ? extend ( options . to , to ) : to ;
570583
0 commit comments