@@ -1203,6 +1203,43 @@ describe("ngAnimate $animateCss", function() {
1203
1203
} ) ;
1204
1204
} ) ;
1205
1205
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
+
1206
1243
it ( 'should apply a custom temporary class when a non-structural animation is used' ,
1207
1244
inject ( function ( $animateCss , $rootElement , $document ) {
1208
1245
0 commit comments