@@ -141,7 +141,6 @@ export function ɵɵanimateEnter(value: string | Function): typeof ɵɵanimateEn
141141 // This also allows us to setup cancellation of animations in progress if the
142142 // gets removed early.
143143 const handleAnimationStart = ( event : AnimationEvent | TransitionEvent ) => {
144- determineLongestAnimation ( event , nativeElement , longestAnimations , areAnimationSupported ) ;
145144 setupAnimationCancel ( event , renderer ) ;
146145 const eventName = event instanceof AnimationEvent ? 'animationend' : 'transitionend' ;
147146 ngZone . runOutsideAngular ( ( ) => {
@@ -175,6 +174,20 @@ export function ɵɵanimateEnter(value: string | Function): typeof ɵɵanimateEn
175174 for ( const klass of activeClasses ) {
176175 renderer . addClass ( nativeElement , klass ) ;
177176 }
177+ // In the case that the classes added have no animations, we need to remove
178+ // the classes right away. This could happen because someone is intentionally
179+ // preventing an animation via selector specificity.
180+ ngZone . runOutsideAngular ( ( ) => {
181+ requestAnimationFrame ( ( ) => {
182+ determineLongestAnimation ( nativeElement , longestAnimations , areAnimationSupported ) ;
183+ if ( ! longestAnimations . has ( nativeElement ) ) {
184+ for ( const klass of activeClasses ) {
185+ renderer . removeClass ( nativeElement , klass ) ;
186+ }
187+ cleanupEnterClassData ( nativeElement ) ;
188+ }
189+ } ) ;
190+ } ) ;
178191 }
179192
180193 return ɵɵanimateEnter ; // For chaining
@@ -504,14 +517,11 @@ function animateLeaveClassRunner(
504517 if ( animationsDisabled ) {
505518 longestAnimations . delete ( el ) ;
506519 finalRemoveFn ( ) ;
520+ return ;
507521 }
508522
509523 cancelAnimationsIfRunning ( el , renderer ) ;
510524
511- const handleAnimationStart = ( event : AnimationEvent | TransitionEvent ) => {
512- determineLongestAnimation ( event , el , longestAnimations , areAnimationSupported ) ;
513- } ;
514-
515525 const handleOutAnimationEnd = ( event : AnimationEvent | TransitionEvent | CustomEvent ) => {
516526 if ( event instanceof CustomEvent || isLongestAnimation ( event , el ) ) {
517527 // Now that we've found the longest animation, there's no need
@@ -525,16 +535,24 @@ function animateLeaveClassRunner(
525535 }
526536 } ;
527537
528- if ( ! animationsDisabled ) {
529- ngZone . runOutsideAngular ( ( ) => {
530- renderer . listen ( el , 'animationstart' , handleAnimationStart , { once : true } ) ;
531- renderer . listen ( el , 'transitionstart' , handleAnimationStart , { once : true } ) ;
532- renderer . listen ( el , 'animationend' , handleOutAnimationEnd ) ;
533- renderer . listen ( el , 'transitionend' , handleOutAnimationEnd ) ;
534- } ) ;
535- trackLeavingNodes ( tNode , el ) ;
536- for ( const item of classList ) {
537- renderer . addClass ( el , item ) ;
538- }
538+ ngZone . runOutsideAngular ( ( ) => {
539+ renderer . listen ( el , 'animationend' , handleOutAnimationEnd ) ;
540+ renderer . listen ( el , 'transitionend' , handleOutAnimationEnd ) ;
541+ } ) ;
542+ trackLeavingNodes ( tNode , el ) ;
543+ for ( const item of classList ) {
544+ renderer . addClass ( el , item ) ;
539545 }
546+ // In the case that the classes added have no animations, we need to remove
547+ // the element right away. This could happen because someone is intentionally
548+ // preventing an animation via selector specificity.
549+ ngZone . runOutsideAngular ( ( ) => {
550+ requestAnimationFrame ( ( ) => {
551+ determineLongestAnimation ( el , longestAnimations , areAnimationSupported ) ;
552+ if ( ! longestAnimations . has ( el ) ) {
553+ clearLeavingNodes ( tNode ) ;
554+ finalRemoveFn ( ) ;
555+ }
556+ } ) ;
557+ } ) ;
540558}
0 commit comments