@@ -12,6 +12,13 @@ describe("ngAnimate $animateCss", function() {
12
12
: expect ( className ) . not . toMatch ( regex ) ;
13
13
}
14
14
15
+ function getPossiblyPrefixedStyleValue ( element , styleProp ) {
16
+ var value = element . css ( prefix + styleProp ) ;
17
+ if ( isUndefined ( value ) ) value = element . css ( styleProp ) ;
18
+
19
+ return value ;
20
+ }
21
+
15
22
function keyframeProgress ( element , duration , delay ) {
16
23
browserTrigger ( element , 'animationend' ,
17
24
{ timeStamp : Date . now ( ) + ( ( delay || 1 ) * 1000 ) , elapsedTime : duration } ) ;
@@ -30,7 +37,8 @@ describe("ngAnimate $animateCss", function() {
30
37
beforeEach ( module ( function ( ) {
31
38
return function ( $document , $sniffer , $$rAF , $animate ) {
32
39
prefix = '-' + $sniffer . vendorPrefix . toLowerCase ( ) + '-' ;
33
- ss = createMockStyleSheet ( $document ) ;
40
+ ss = createMockStyleSheet ( $document , prefix ) ;
41
+
34
42
$animate . enabled ( true ) ;
35
43
triggerAnimationStartFrame = function ( ) {
36
44
$$rAF . flush ( ) ;
@@ -325,7 +333,7 @@ describe("ngAnimate $animateCss", function() {
325
333
triggerAnimationStartFrame ( ) ;
326
334
327
335
runner . pause ( ) ;
328
- expect ( element . css ( prefix + 'animation-play-state' ) ) . toEqual ( 'paused' ) ;
336
+ expect ( getPossiblyPrefixedStyleValue ( element , 'animation-play-state' ) ) . toEqual ( 'paused' ) ;
329
337
runner . resume ( ) ;
330
338
expect ( element . attr ( 'style' ) ) . toBeFalsy ( ) ;
331
339
} ) ) ;
@@ -346,7 +354,7 @@ describe("ngAnimate $animateCss", function() {
346
354
triggerAnimationStartFrame ( ) ;
347
355
348
356
runner . pause ( ) ;
349
- expect ( element . css ( prefix + 'animation-play-state' ) ) . toEqual ( 'paused' ) ;
357
+ expect ( getPossiblyPrefixedStyleValue ( element , 'animation-play-state' ) ) . toEqual ( 'paused' ) ;
350
358
runner . end ( ) ;
351
359
expect ( element . attr ( 'style' ) ) . toBeFalsy ( ) ;
352
360
} ) ) ;
@@ -784,8 +792,8 @@ describe("ngAnimate $animateCss", function() {
784
792
785
793
jqLite ( $document [ 0 ] . body ) . append ( $rootElement ) ;
786
794
787
- ss . addRule ( '.ng-enter-stagger' , prefix + 'animation-delay:0.2s' ) ;
788
- ss . addRule ( '.ng-enter' , prefix + 'animation:my_animation 2s;' ) ;
795
+ ss . addPossiblyPrefixedRule ( '.ng-enter-stagger' , 'animation-delay:0.2s' ) ;
796
+ ss . addPossiblyPrefixedRule ( '.ng-enter' , 'animation:my_animation 2s;' ) ;
789
797
790
798
var i , element , elements = [ ] ;
791
799
for ( i = 0 ; i < 5 ; i ++ ) {
@@ -803,7 +811,7 @@ describe("ngAnimate $animateCss", function() {
803
811
if ( i === 0 ) { // the first element is always run right away
804
812
expect ( element . attr ( 'style' ) ) . toBeFalsy ( ) ;
805
813
} else {
806
- expect ( element . css ( prefix + 'animation-play-state' ) ) . toBe ( 'paused' ) ;
814
+ expect ( getPossiblyPrefixedStyleValue ( element , 'animation-play-state' ) ) . toBe ( 'paused' ) ;
807
815
}
808
816
}
809
817
} ) ) ;
@@ -879,7 +887,7 @@ describe("ngAnimate $animateCss", function() {
879
887
jqLite ( $document [ 0 ] . body ) . append ( $rootElement ) ;
880
888
881
889
ss . addRule ( '.ng-enter-stagger' , 'transition-delay:0.2s' ) ;
882
- ss . addRule ( '.transition-animation' , prefix + 'animation:2s 5s my_animation;' ) ;
890
+ ss . addPossiblyPrefixedRule ( '.transition-animation' , 'animation: 2s 5s my_animation;' ) ;
883
891
884
892
for ( var i = 0 ; i < 5 ; i ++ ) {
885
893
var elm = jqLite ( '<div class="transition-animation"></div>' ) ;
@@ -898,11 +906,11 @@ describe("ngAnimate $animateCss", function() {
898
906
899
907
jqLite ( $document [ 0 ] . body ) . append ( $rootElement ) ;
900
908
901
- ss . addRule ( '.ng-enter-stagger' , 'transition-delay:0.5s;' +
902
- prefix + 'animation-delay:1s' ) ;
909
+ ss . addPossiblyPrefixedRule ( '.ng-enter-stagger' , 'transition-delay: 0.5s; ' +
910
+ 'animation-delay: 1s' ) ;
903
911
904
- ss . addRule ( '.ng-enter' , 'transition:10s linear all;' +
905
- prefix + 'animation:my_animation 20s' ) ;
912
+ ss . addPossiblyPrefixedRule ( '.ng-enter' , 'transition: 10s linear all; ' +
913
+ 'animation: 20s my_animation ' ) ;
906
914
907
915
var i , elm , elements = [ ] ;
908
916
for ( i = 0 ; i < 5 ; i ++ ) {
@@ -1258,14 +1266,14 @@ describe("ngAnimate $animateCss", function() {
1258
1266
// At this point, the animation should still be running (closing timeout is 7500ms ... duration * 1.5 + delay => 7.5)
1259
1267
$timeout . flush ( 7000 ) ;
1260
1268
1261
- expect ( element . css ( prefix + 'transition-delay' ) ) . toBe ( '3s' ) ;
1262
- expect ( element . css ( prefix + 'transition-duration' ) ) . toBe ( '3s' ) ;
1269
+ expect ( getPossiblyPrefixedStyleValue ( element , 'transition-delay' ) ) . toBe ( '3s' ) ;
1270
+ expect ( getPossiblyPrefixedStyleValue ( element , 'transition-duration' ) ) . toBe ( '3s' ) ;
1263
1271
1264
1272
// Let's flush the remaining amount of time for the timeout timer to kick in
1265
1273
$timeout . flush ( 500 ) ;
1266
1274
1267
- expect ( element . css ( prefix + 'transition-duration' ) ) . toBeOneOf ( '' , '0s' ) ;
1268
- expect ( element . css ( prefix + 'transition-delay' ) ) . toBeOneOf ( '' , '0s' ) ;
1275
+ expect ( getPossiblyPrefixedStyleValue ( element , 'transition-duration' ) ) . toBeOneOf ( '' , '0s' ) ;
1276
+ expect ( getPossiblyPrefixedStyleValue ( element , 'transition-delay' ) ) . toBeOneOf ( '' , '0s' ) ;
1269
1277
} ) ) ;
1270
1278
1271
1279
it ( "should ignore a boolean options.delay value for the closing timeout" ,
@@ -1291,14 +1299,14 @@ describe("ngAnimate $animateCss", function() {
1291
1299
// At this point, the animation should still be running (closing timeout is 4500ms ... duration * 1.5 => 4.5)
1292
1300
$timeout . flush ( 4000 ) ;
1293
1301
1294
- expect ( element . css ( prefix + 'transition-delay' ) ) . toBeOneOf ( 'initial' , '0s' ) ;
1295
- expect ( element . css ( prefix + 'transition-duration' ) ) . toBe ( '3s' ) ;
1302
+ expect ( getPossiblyPrefixedStyleValue ( element , 'transition-delay' ) ) . toBeOneOf ( 'initial' , '0s' ) ;
1303
+ expect ( getPossiblyPrefixedStyleValue ( element , 'transition-duration' ) ) . toBe ( '3s' ) ;
1296
1304
1297
1305
// Let's flush the remaining amount of time for the timeout timer to kick in
1298
1306
$timeout . flush ( 500 ) ;
1299
1307
1300
- expect ( element . css ( prefix + 'transition-duration' ) ) . toBeOneOf ( '' , '0s' ) ;
1301
- expect ( element . css ( prefix + 'transition-delay' ) ) . toBeOneOf ( '' , '0s' ) ;
1308
+ expect ( getPossiblyPrefixedStyleValue ( element , 'transition-duration' ) ) . toBeOneOf ( '' , '0s' ) ;
1309
+ expect ( getPossiblyPrefixedStyleValue ( element , 'transition-delay' ) ) . toBeOneOf ( '' , '0s' ) ;
1302
1310
} ) ) ;
1303
1311
1304
1312
} ) ;
@@ -2104,7 +2112,7 @@ describe("ngAnimate $animateCss", function() {
2104
2112
triggerAnimationStartFrame ( ) ;
2105
2113
2106
2114
2107
- expect ( element . css ( prefix + 'animation-duration' ) ) . toEqual ( '5s' ) ;
2115
+ expect ( getPossiblyPrefixedStyleValue ( element , 'animation-duration' ) ) . toEqual ( '5s' ) ;
2108
2116
} ) ) ;
2109
2117
2110
2118
it ( "should remove all inline keyframe styling when an animation completes if a custom duration was applied" ,
@@ -2145,7 +2153,7 @@ describe("ngAnimate $animateCss", function() {
2145
2153
triggerAnimationStartFrame ( ) ;
2146
2154
2147
2155
2148
- expect ( element . css ( prefix + 'animation-delay' ) ) . toEqual ( '5s' ) ;
2156
+ expect ( getPossiblyPrefixedStyleValue ( element , 'animation-delay' ) ) . toEqual ( '5s' ) ;
2149
2157
2150
2158
browserTrigger ( element , 'animationend' ,
2151
2159
{ timeStamp : Date . now ( ) + 5000 , elapsedTime : 1.5 } ) ;
@@ -2299,7 +2307,7 @@ describe("ngAnimate $animateCss", function() {
2299
2307
triggerAnimationStartFrame ( ) ;
2300
2308
2301
2309
2302
- expect ( element . css ( prefix + 'animation-delay' ) ) . toEqual ( '400s' ) ;
2310
+ expect ( getPossiblyPrefixedStyleValue ( element , 'animation-delay' ) ) . toEqual ( '400s' ) ;
2303
2311
expect ( element . attr ( 'style' ) ) . not . toContain ( 'transition-delay' ) ;
2304
2312
} ) ) ;
2305
2313
@@ -2323,7 +2331,7 @@ describe("ngAnimate $animateCss", function() {
2323
2331
triggerAnimationStartFrame ( ) ;
2324
2332
2325
2333
2326
- expect ( element . css ( prefix + 'animation-delay' ) ) . toEqual ( '10s' ) ;
2334
+ expect ( getPossiblyPrefixedStyleValue ( element , 'animation-delay' ) ) . toEqual ( '10s' ) ;
2327
2335
expect ( element . css ( 'transition-delay' ) ) . toEqual ( '10s' ) ;
2328
2336
} ) ) ;
2329
2337
@@ -2363,7 +2371,7 @@ describe("ngAnimate $animateCss", function() {
2363
2371
var assertionsRun = false ;
2364
2372
classSpy = function ( ) {
2365
2373
assertionsRun = true ;
2366
- expect ( element . css ( prefix + 'animation-delay' ) ) . toEqual ( '2s' ) ;
2374
+ expect ( getPossiblyPrefixedStyleValue ( element , 'animation-delay' ) ) . toEqual ( '2s' ) ;
2367
2375
expect ( element . css ( 'transition-delay' ) ) . toEqual ( '2s' ) ;
2368
2376
expect ( element ) . not . toHaveClass ( 'superman' ) ;
2369
2377
} ;
@@ -2397,8 +2405,8 @@ describe("ngAnimate $animateCss", function() {
2397
2405
it ( "should consider a negative value when delay:true is used with a keyframe animation" ,
2398
2406
inject ( function ( $animateCss , $rootElement ) {
2399
2407
2400
- ss . addRule ( '.ng-enter' , prefix + 'animation:2s keyframe_animation; ' +
2401
- prefix + 'animation-delay: -1s;' ) ;
2408
+ ss . addPossiblyPrefixedRule ( '.ng-enter' , 'animation: 2s keyframe_animation; ' +
2409
+ 'animation-delay: -1s;' ) ;
2402
2410
2403
2411
var options = {
2404
2412
delay : true ,
@@ -2411,7 +2419,7 @@ describe("ngAnimate $animateCss", function() {
2411
2419
animator . start ( ) ;
2412
2420
triggerAnimationStartFrame ( ) ;
2413
2421
2414
- expect ( element . css ( prefix + 'animation-delay' ) ) . toContain ( '-1s' ) ;
2422
+ expect ( getPossiblyPrefixedStyleValue ( element , 'animation-delay' ) ) . toContain ( '-1s' ) ;
2415
2423
} ) ) ;
2416
2424
2417
2425
they ( "should consider a negative value when a negative option delay is provided for a $prop animation" , {
@@ -2421,17 +2429,17 @@ describe("ngAnimate $animateCss", function() {
2421
2429
css : 'transition:2s linear all'
2422
2430
} ;
2423
2431
} ,
2424
- 'keyframe' : function ( prefix ) {
2432
+ 'keyframe' : function ( ) {
2425
2433
return {
2426
- prop : prefix + 'animation-delay' ,
2427
- css : prefix + 'animation:2s keyframe_animation'
2434
+ prop : 'animation-delay' ,
2435
+ css : 'animation: 2s keyframe_animation'
2428
2436
} ;
2429
2437
}
2430
2438
} , function ( testDetailsFactory ) {
2431
2439
inject ( function ( $animateCss , $rootElement ) {
2432
2440
var testDetails = testDetailsFactory ( prefix ) ;
2433
2441
2434
- ss . addRule ( '.ng-enter' , testDetails . css ) ;
2442
+ ss . addPossiblyPrefixedRule ( '.ng-enter' , testDetails . css ) ;
2435
2443
var options = {
2436
2444
delay : - 2 ,
2437
2445
event : 'enter' ,
@@ -2443,7 +2451,7 @@ describe("ngAnimate $animateCss", function() {
2443
2451
animator . start ( ) ;
2444
2452
triggerAnimationStartFrame ( ) ;
2445
2453
2446
- expect ( element . css ( testDetails . prop ) ) . toContain ( '-2s' ) ;
2454
+ expect ( getPossiblyPrefixedStyleValue ( element , testDetails . prop ) ) . toContain ( '-2s' ) ;
2447
2455
} ) ;
2448
2456
} ) ;
2449
2457
@@ -2454,18 +2462,18 @@ describe("ngAnimate $animateCss", function() {
2454
2462
css : 'transition:5s linear all; transition-delay: -2s'
2455
2463
} ;
2456
2464
} ,
2457
- 'animation' : function ( prefix ) {
2465
+ 'animation' : function ( ) {
2458
2466
return {
2459
2467
event : 'animationend' ,
2460
- css : prefix + 'animation:5s keyframe_animation; ' + prefix + ' animation-delay: -2s;'
2468
+ css : 'animation: 5s keyframe_animation; animation-delay: -2s;'
2461
2469
} ;
2462
2470
}
2463
2471
} , function ( testDetailsFactory ) {
2464
2472
inject ( function ( $animateCss , $rootElement ) {
2465
- var testDetails = testDetailsFactory ( prefix ) ;
2473
+ var testDetails = testDetailsFactory ( ) ;
2466
2474
var event = testDetails . event ;
2467
2475
2468
- ss . addRule ( '.ng-enter' , testDetails . css ) ;
2476
+ ss . addPossiblyPrefixedRule ( '.ng-enter' , testDetails . css ) ;
2469
2477
var options = { event : 'enter' , structural : true } ;
2470
2478
2471
2479
var animator = $animateCss ( element , options ) ;
@@ -2571,15 +2579,15 @@ describe("ngAnimate $animateCss", function() {
2571
2579
$animateCss ( element , options ) . start ( ) ;
2572
2580
triggerAnimationStartFrame ( ) ;
2573
2581
2574
- expect ( element . css ( prefix + 'transition-delay' ) ) . not . toEqual ( '4s' ) ;
2575
- expect ( element . css ( prefix + 'transition-duration' ) ) . not . toEqual ( '6s' ) ;
2582
+ expect ( getPossiblyPrefixedStyleValue ( element , 'transition-delay' ) ) . not . toEqual ( '4s' ) ;
2583
+ expect ( getPossiblyPrefixedStyleValue ( element , 'transition-duration' ) ) . not . toEqual ( '6s' ) ;
2576
2584
2577
2585
options . to = { color : 'brown' } ;
2578
2586
$animateCss ( element , options ) . start ( ) ;
2579
2587
triggerAnimationStartFrame ( ) ;
2580
2588
2581
- expect ( element . css ( prefix + 'transition-delay' ) ) . toEqual ( '4s' ) ;
2582
- expect ( element . css ( prefix + 'transition-duration' ) ) . toEqual ( '6s' ) ;
2589
+ expect ( getPossiblyPrefixedStyleValue ( element , 'transition-delay' ) ) . toEqual ( '4s' ) ;
2590
+ expect ( getPossiblyPrefixedStyleValue ( element , 'transition-duration' ) ) . toEqual ( '6s' ) ;
2583
2591
} ) ) ;
2584
2592
} ) ;
2585
2593
@@ -2652,9 +2660,9 @@ describe("ngAnimate $animateCss", function() {
2652
2660
triggerAnimationStartFrame ( ) ;
2653
2661
2654
2662
2655
- expect ( element . css ( prefix + 'animation-delay' ) ) . toEqual ( '50s' ) ;
2656
- expect ( element . css ( prefix + 'animation-duration' ) ) . toEqual ( '5.5s' ) ;
2657
- expect ( element . css ( prefix + 'animation-name' ) ) . toEqual ( 'my_animation' ) ;
2663
+ expect ( getPossiblyPrefixedStyleValue ( element , 'animation-delay' ) ) . toEqual ( '50s' ) ;
2664
+ expect ( getPossiblyPrefixedStyleValue ( element , 'animation-duration' ) ) . toEqual ( '5.5s' ) ;
2665
+ expect ( getPossiblyPrefixedStyleValue ( element , 'animation-name' ) ) . toEqual ( 'my_animation' ) ;
2658
2666
} ) ) ;
2659
2667
2660
2668
it ( "should be able to execute the animation if it is the only provided value" ,
@@ -2669,9 +2677,9 @@ describe("ngAnimate $animateCss", function() {
2669
2677
animator . start ( ) ;
2670
2678
triggerAnimationStartFrame ( ) ;
2671
2679
2672
- expect ( element . css ( prefix + 'animation-delay' ) ) . toEqual ( '10s' ) ;
2673
- expect ( element . css ( prefix + 'animation-duration' ) ) . toEqual ( '5.5s' ) ;
2674
- expect ( element . css ( prefix + 'animation-name' ) ) . toEqual ( 'my_animation' ) ;
2680
+ expect ( getPossiblyPrefixedStyleValue ( element , 'animation-delay' ) ) . toEqual ( '10s' ) ;
2681
+ expect ( getPossiblyPrefixedStyleValue ( element , 'animation-duration' ) ) . toEqual ( '5.5s' ) ;
2682
+ expect ( getPossiblyPrefixedStyleValue ( element , 'animation-name' ) ) . toEqual ( 'my_animation' ) ;
2675
2683
} ) ) ;
2676
2684
} ) ;
2677
2685
@@ -2964,7 +2972,7 @@ describe("ngAnimate $animateCss", function() {
2964
2972
2965
2973
2966
2974
expect ( element . css ( 'transition-duration' ) ) . toMatch ( '10s' ) ;
2967
- expect ( element . css ( prefix + 'animation-duration' ) ) . toEqual ( '10s' ) ;
2975
+ expect ( getPossiblyPrefixedStyleValue ( element , 'animation-duration' ) ) . toEqual ( '10s' ) ;
2968
2976
} ) ) ;
2969
2977
} ) ;
2970
2978
@@ -3004,7 +3012,7 @@ describe("ngAnimate $animateCss", function() {
3004
3012
inject ( function ( $animateCss ) {
3005
3013
3006
3014
ss . addRule ( '.red' , 'transition: 1s linear all;' ) ;
3007
- ss . addRule ( '.blue' , prefix + 'animation:my_keyframe 1s;' ) ;
3015
+ ss . addPossiblyPrefixedRule ( '.blue' , 'animation: 1s my_keyframe ;' ) ;
3008
3016
var easing = 'ease-out' ;
3009
3017
var animator = $animateCss ( element , { addClass : 'red blue' , easing : easing } ) ;
3010
3018
animator . start ( ) ;
0 commit comments