@@ -302,15 +302,6 @@ function localizeDeclNode(node, context) {
302
302
return node ;
303
303
}
304
304
305
- function isWordAFunctionArgument ( wordNode , functionNode ) {
306
- return functionNode
307
- ? functionNode . nodes . some (
308
- ( functionNodeChild ) =>
309
- functionNodeChild . sourceIndex === wordNode . sourceIndex
310
- )
311
- : false ;
312
- }
313
-
314
305
// `none` is special value, other is global values
315
306
const specialKeywords = [
316
307
"none" ,
@@ -373,51 +364,59 @@ function localizeDeclaration(declaration, context) {
373
364
animation name of infinite from the second.
374
365
*/
375
366
const animationKeywords = {
367
+ // animation-direction
368
+ $normal : 1 ,
369
+ $reverse : 1 ,
376
370
$alternate : 1 ,
377
371
"$alternate-reverse" : 1 ,
372
+ // animation-fill-mode
373
+ $forwards : 1 ,
378
374
$backwards : 1 ,
379
375
$both : 1 ,
376
+ // animation-iteration-count
377
+ $infinite : 1 ,
378
+ // animation-play-state
379
+ $paused : 1 ,
380
+ $running : 1 ,
381
+ // animation-timing-function
380
382
$ease : 1 ,
381
383
"$ease-in" : 1 ,
382
- "$ease-in-out" : 1 ,
383
384
"$ease-out" : 1 ,
384
- $forwards : 1 ,
385
- $infinite : 1 ,
385
+ "$ease-in-out" : 1 ,
386
386
$linear : 1 ,
387
- $none : Infinity , // No matter how many times you write none, it will never be an animation name
388
- $normal : 1 ,
389
- $paused : 1 ,
390
- $reverse : 1 ,
391
- $running : 1 ,
392
387
"$step-end" : 1 ,
393
388
"$step-start" : 1 ,
389
+ // Special
390
+ $none : Infinity , // No matter how many times you write none, it will never be an animation name
391
+ // Global values
394
392
$initial : Infinity ,
395
393
$inherit : Infinity ,
396
394
$unset : Infinity ,
397
395
$revert : Infinity ,
398
396
"$revert-layer" : Infinity ,
399
397
} ;
400
-
401
- const didParseAnimationName = false ;
402
398
let parsedAnimationKeywords = { } ;
403
- let stepsFunctionNode = null ;
404
399
const valueNodes = valueParser ( declaration . value ) . walk ( ( node ) => {
405
- /* If div-token appeared (represents as comma ','), a possibility of an animation-keywords should be reflesh. */
400
+ // If div-token appeared (represents as comma ','), a possibility of an animation-keywords should be reflesh.
406
401
if ( node . type === "div" ) {
407
402
parsedAnimationKeywords = { } ;
403
+
404
+ return ;
405
+ }
406
+ // Do not handle nested functions
407
+ else if ( node . type === "function" ) {
408
+ return false ;
408
409
}
409
- if ( node . type === "function" && node . value . toLowerCase ( ) === "steps" ) {
410
- stepsFunctionNode = node ;
410
+ // Ignore all except word
411
+ else if ( node . type !== "word" ) {
412
+ return ;
411
413
}
412
- const value =
413
- node . type === "word" &&
414
- ! isWordAFunctionArgument ( node , stepsFunctionNode )
415
- ? node . value . toLowerCase ( )
416
- : null ;
414
+
415
+ const value = node . type === "word" ? node . value . toLowerCase ( ) : null ;
417
416
418
417
let shouldParseAnimationName = false ;
419
418
420
- if ( ! didParseAnimationName && value && validIdent . test ( value ) ) {
419
+ if ( value && validIdent . test ( value ) ) {
421
420
if ( "$" + value in animationKeywords ) {
422
421
parsedAnimationKeywords [ "$" + value ] =
423
422
"$" + value in parsedAnimationKeywords
@@ -438,6 +437,7 @@ function localizeDeclaration(declaration, context) {
438
437
localizeNextItem : shouldParseAnimationName && ! context . global ,
439
438
localAliasMap : context . localAliasMap ,
440
439
} ;
440
+
441
441
return localizeDeclNode ( node , subContext ) ;
442
442
} ) ;
443
443
0 commit comments