@@ -543,6 +543,42 @@ describe("ngAnimate", function() {
543
543
} ) ;
544
544
} ) ;
545
545
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
+ element [ 0 ] . removeChild ( child [ 0 ] ) ;
559
+
560
+ var orphanChild = jqLite ( '<div class="track-me"></div>' ) ;
561
+ var doneSpy = jasmine . createSpy ( ) ;
562
+
563
+ $animate . setClass ( orphanChild , 'red' , 'blue' ) . then ( doneSpy ) ;
564
+ $rootScope . $digest ( ) ;
565
+ $animate . triggerCallbacks ( ) ;
566
+
567
+ expect ( doneSpy ) . toHaveBeenCalled ( ) ;
568
+ expect ( animateSpy ) . not . toHaveBeenCalled ( ) ;
569
+
570
+ element . append ( orphanChild ) ;
571
+
572
+ $animate . setClass ( orphanChild , 'blue' , 'gold' ) . then ( doneSpy ) ;
573
+ $rootScope . $digest ( ) ;
574
+ $animate . triggerReflow ( ) ;
575
+ $animate . triggerCallbacks ( ) ;
576
+
577
+ expect ( animateSpy ) . toHaveBeenCalled ( ) ;
578
+ } ) ;
579
+ } ) ;
580
+
581
+
546
582
it ( "should exclusively animate the setClass animation event with native dom elements" , function ( ) {
547
583
var count = 0 , fallback = jasmine . createSpy ( 'callback' ) ;
548
584
module ( function ( $animateProvider ) {
@@ -4558,8 +4594,10 @@ describe("ngAnimate", function() {
4558
4594
} ;
4559
4595
} ) ;
4560
4596
} ) ;
4561
- inject ( function ( $compile , $rootScope , $animate , $sniffer , $rootElement ) {
4597
+ inject ( function ( $compile , $rootScope , $animate , $sniffer , $rootElement , $document ) {
4562
4598
4599
+ var body = jqLite ( $document [ 0 ] . body ) ;
4600
+ body . append ( $rootElement ) ;
4563
4601
$rootElement . addClass ( 'animated' ) ;
4564
4602
$animate . addClass ( $rootElement , 'green' ) ;
4565
4603
$rootScope . $digest ( ) ;
@@ -5417,9 +5455,11 @@ describe("ngAnimate", function() {
5417
5455
}
5418
5456
5419
5457
5420
- it ( 'should defer class manipulation until end of digest' , inject ( function ( $rootScope , $animate , log ) {
5458
+ it ( 'should defer class manipulation until end of digest' , inject ( function ( $rootScope , $animate , log , $document , $rootElement ) {
5421
5459
setupClassManipulationLogger ( log ) ;
5422
5460
element = jqLite ( '<p>test</p>' ) ;
5461
+ jqLite ( $document [ 0 ] . body ) . append ( $rootElement ) ;
5462
+ $rootElement . append ( element ) ;
5423
5463
5424
5464
$rootScope . $apply ( function ( ) {
5425
5465
$animate . addClass ( element , 'test-class1' ) ;
@@ -5446,9 +5486,11 @@ describe("ngAnimate", function() {
5446
5486
} ) ) ;
5447
5487
5448
5488
5449
- it ( 'should defer class manipulation until postDigest when outside of digest' , inject ( function ( $rootScope , $animate , log ) {
5489
+ it ( 'should defer class manipulation until postDigest when outside of digest' , inject ( function ( $rootScope , $animate , log , $document , $rootElement ) {
5450
5490
setupClassManipulationLogger ( log ) ;
5451
5491
element = jqLite ( '<p class="test-class4">test</p>' ) ;
5492
+ jqLite ( $document [ 0 ] . body ) . append ( $rootElement ) ;
5493
+ $rootElement . append ( element ) ;
5452
5494
5453
5495
$animate . addClass ( element , 'test-class1' ) ;
5454
5496
$animate . removeClass ( element , 'test-class1' ) ;
@@ -5467,8 +5509,10 @@ describe("ngAnimate", function() {
5467
5509
} ) ) ;
5468
5510
5469
5511
5470
- it ( 'should perform class manipulation in expected order at end of digest' , inject ( function ( $rootScope , $animate , log ) {
5512
+ it ( 'should perform class manipulation in expected order at end of digest' , inject ( function ( $rootScope , $animate , log , $rootElement , $document ) {
5471
5513
element = jqLite ( '<p class="test-class3">test</p>' ) ;
5514
+ jqLite ( $document [ 0 ] . body ) . append ( $rootElement ) ;
5515
+ $rootElement . append ( element ) ;
5472
5516
5473
5517
setupClassManipulationLogger ( log ) ;
5474
5518
0 commit comments