@@ -281,10 +281,13 @@ function analyze(css) {
281281 break
282282 }
283283
284- if ( endsWith ( '\\9' , node . unit ) ) {
285- units . push ( node . unit . substring ( 0 , node . unit . length - 2 ) , this . declaration . property )
284+ /** @type {string } */
285+ let unit = node . unit
286+
287+ if ( endsWith ( '\\9' , unit ) ) {
288+ units . push ( unit . substring ( 0 , unit . length - 2 ) , this . declaration . property )
286289 } else {
287- units . push ( node . unit , this . declaration . property )
290+ units . push ( unit , this . declaration . property )
288291 }
289292
290293 return this . skip
@@ -400,6 +403,8 @@ function analyze(css) {
400403 }
401404
402405 walk ( node , function ( valueNode ) {
406+ let nodeName = valueNode . name
407+
403408 switch ( valueNode . type ) {
404409 case 'Hash' : {
405410 let hexLength = valueNode . value . length
@@ -412,15 +417,14 @@ function analyze(css) {
412417 return this . skip
413418 }
414419 case 'Identifier' : {
415- let { name } = valueNode
416420 // Bail out if it can't be a color name
417421 // 20 === 'lightgoldenrodyellow'.length
418422 // 3 === 'red'.length
419- if ( name . length > 20 || name . length < 3 ) {
423+ if ( nodeName . length > 20 || nodeName . length < 3 ) {
420424 return this . skip
421425 }
422426 let stringified = stringifyNode ( valueNode )
423- let lowerCased = name . toLowerCase ( )
427+ let lowerCased = nodeName . toLowerCase ( )
424428
425429 if ( namedColors . has ( lowerCased ) ) {
426430 colors . push ( stringified , property )
@@ -436,10 +440,10 @@ function analyze(css) {
436440 }
437441 case 'Function' : {
438442 // Don't walk var() multiple times
439- if ( strEquals ( 'var' , valueNode . name ) ) {
443+ if ( strEquals ( 'var' , nodeName ) ) {
440444 return this . skip
441445 }
442- let fnName = valueNode . name . toLowerCase ( )
446+ let fnName = nodeName . toLowerCase ( )
443447 let stringified = stringifyNode ( valueNode )
444448 if ( colorFunctions . has ( fnName ) ) {
445449 colors . push ( stringified , property )
0 commit comments