@@ -1203,6 +1203,43 @@ describe("ngAnimate $animateCss", function() {
12031203 } ) ;
12041204 } ) ;
12051205
1206+ it ( 'should avoid applying the same cache to an element a follow-up animation is run on the same element' ,
1207+ inject ( function ( $animateCss , $rootElement , $document ) {
1208+
1209+ function endTransition ( element , elapsedTime ) {
1210+ browserTrigger ( element , 'transitionend' ,
1211+ { timeStamp : Date . now ( ) , elapsedTime : elapsedTime } ) ;
1212+ }
1213+
1214+ function startAnimation ( element , duration , color ) {
1215+ $animateCss ( element , {
1216+ duration : duration ,
1217+ to : { background : color }
1218+ } ) . start ( ) ;
1219+ triggerAnimationStartFrame ( ) ;
1220+ }
1221+
1222+ var element = jqLite ( '<div></div>' ) ;
1223+ $rootElement . append ( element ) ;
1224+ jqLite ( $document [ 0 ] . body ) . append ( $rootElement ) ;
1225+
1226+ startAnimation ( element , 0.5 , 'red' ) ;
1227+ expect ( element . attr ( 'style' ) ) . toContain ( 'transition' ) ;
1228+
1229+ endTransition ( element , 0.5 ) ;
1230+ expect ( element . attr ( 'style' ) ) . not . toContain ( 'transition' ) ;
1231+
1232+ startAnimation ( element , 0.8 , 'blue' ) ;
1233+ expect ( element . attr ( 'style' ) ) . toContain ( 'transition' ) ;
1234+
1235+ // Trigger an extra transitionend event that matches the original transition
1236+ endTransition ( element , 0.5 ) ;
1237+ expect ( element . attr ( 'style' ) ) . toContain ( 'transition' ) ;
1238+
1239+ endTransition ( element , 0.8 ) ;
1240+ expect ( element . attr ( 'style' ) ) . not . toContain ( 'transition' ) ;
1241+ } ) ) ;
1242+
12061243 it ( 'should apply a custom temporary class when a non-structural animation is used' ,
12071244 inject ( function ( $animateCss , $rootElement , $document ) {
12081245
0 commit comments