@@ -543,6 +543,44 @@ describe("ngAnimate", function() {
543543 } ) ;
544544 } ) ;
545545
546+ it ( "should clear the setClass element animation cache before the next animation runs" , function ( ) {
547+ var animateSpy = jasmine . createSpy ( ) ;
548+ module ( function ( $animateProvider ) {
549+ $animateProvider . register ( '.track-me' , function ( ) {
550+ return {
551+ addClass : animateSpy ,
552+ removeClass : animateSpy ,
553+ setClass : animateSpy
554+ } ;
555+ } ) ;
556+ } ) ;
557+ inject ( function ( $animate , $rootScope , $sniffer , $$rAF ) {
558+ var orphanChild = jqLite ( '<div class="track-me"></div>' ) ;
559+ element . append ( orphanChild ) ;
560+ orphanChild . remove ( ) ;
561+
562+ var doneSpy = jasmine . createSpy ( ) ;
563+
564+ $animate . setClass ( orphanChild , 'red' , 'blue' ) . then ( doneSpy ) ;
565+ $rootScope . $digest ( ) ;
566+ $animate . triggerCallbacks ( ) ;
567+
568+ expect ( doneSpy ) . toHaveBeenCalled ( ) ;
569+ expect ( animateSpy ) . not . toHaveBeenCalled ( ) ;
570+
571+ var specialChild = jqLite ( '<div class="track-me"></div>' ) ;
572+ element . append ( specialChild ) ;
573+
574+ $animate . setClass ( specialChild , 'blue' , 'gold' ) . then ( doneSpy ) ;
575+ $rootScope . $digest ( ) ;
576+ $animate . triggerReflow ( ) ;
577+ $animate . triggerCallbacks ( ) ;
578+
579+ expect ( animateSpy ) . toHaveBeenCalled ( ) ;
580+ } ) ;
581+ } ) ;
582+
583+
546584 it ( "should exclusively animate the setClass animation event with native dom elements" , function ( ) {
547585 var count = 0 , fallback = jasmine . createSpy ( 'callback' ) ;
548586 module ( function ( $animateProvider ) {
@@ -4559,8 +4597,8 @@ describe("ngAnimate", function() {
45594597 } ) ;
45604598 } ) ;
45614599 inject ( function ( $compile , $rootScope , $animate , $sniffer , $rootElement ) {
4562-
45634600 $rootElement . addClass ( 'animated' ) ;
4601+
45644602 $animate . addClass ( $rootElement , 'green' ) ;
45654603 $rootScope . $digest ( ) ;
45664604 $animate . triggerReflow ( ) ;
0 commit comments