@@ -302,15 +302,6 @@ function localizeDeclNode(node, context) {
302302 return node ;
303303}
304304
305- function isWordAFunctionArgument ( wordNode , functionNode ) {
306- return functionNode
307- ? functionNode . nodes . some (
308- ( functionNodeChild ) =>
309- functionNodeChild . sourceIndex === wordNode . sourceIndex
310- )
311- : false ;
312- }
313-
314305// `none` is special value, other is global values
315306const specialKeywords = [
316307 "none" ,
@@ -373,51 +364,59 @@ function localizeDeclaration(declaration, context) {
373364 animation name of infinite from the second.
374365 */
375366 const animationKeywords = {
367+ // animation-direction
368+ $normal : 1 ,
369+ $reverse : 1 ,
376370 $alternate : 1 ,
377371 "$alternate-reverse" : 1 ,
372+ // animation-fill-mode
373+ $forwards : 1 ,
378374 $backwards : 1 ,
379375 $both : 1 ,
376+ // animation-iteration-count
377+ $infinite : 1 ,
378+ // animation-play-state
379+ $paused : 1 ,
380+ $running : 1 ,
381+ // animation-timing-function
380382 $ease : 1 ,
381383 "$ease-in" : 1 ,
382- "$ease-in-out" : 1 ,
383384 "$ease-out" : 1 ,
384- $forwards : 1 ,
385- $infinite : 1 ,
385+ "$ease-in-out" : 1 ,
386386 $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 ,
392387 "$step-end" : 1 ,
393388 "$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
394392 $initial : Infinity ,
395393 $inherit : Infinity ,
396394 $unset : Infinity ,
397395 $revert : Infinity ,
398396 "$revert-layer" : Infinity ,
399397 } ;
400-
401- const didParseAnimationName = false ;
402398 let parsedAnimationKeywords = { } ;
403- let stepsFunctionNode = null ;
404399 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.
406401 if ( node . type === "div" ) {
407402 parsedAnimationKeywords = { } ;
403+
404+ return ;
405+ }
406+ // Do not handle nested functions
407+ else if ( node . type === "function" ) {
408+ return false ;
408409 }
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 ;
411413 }
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 ;
417416
418417 let shouldParseAnimationName = false ;
419418
420- if ( ! didParseAnimationName && value && validIdent . test ( value ) ) {
419+ if ( value && validIdent . test ( value ) ) {
421420 if ( "$" + value in animationKeywords ) {
422421 parsedAnimationKeywords [ "$" + value ] =
423422 "$" + value in parsedAnimationKeywords
@@ -438,6 +437,7 @@ function localizeDeclaration(declaration, context) {
438437 localizeNextItem : shouldParseAnimationName && ! context . global ,
439438 localAliasMap : context . localAliasMap ,
440439 } ;
440+
441441 return localizeDeclNode ( node , subContext ) ;
442442 } ) ;
443443
0 commit comments