@@ -17,7 +17,7 @@ import { isSupportsBrowserhack, isMediaBrowserhack } from './atrules/atrules.js'
1717import { getCombinators , getComplexity , isPrefixed , hasPseudoClass , isAccessibility } from './selectors/utils.js'
1818import { calculateForAST as calculateSpecificity } from './selectors/specificity.js'
1919import { colorFunctions , colorKeywords , namedColors , systemColors } from './values/colors.js'
20- import { destructure , isSystemFont } from './values/destructure-font-shorthand.js'
20+ import { destructure , isSystemFont , SYSTEM_FONTS } from './values/destructure-font-shorthand.js'
2121import { isValueKeyword , keywords , isValueReset } from './values/values.js'
2222import { analyzeAnimation } from './values/animations.js'
2323import { isValuePrefixed } from './values/vendor-prefix.js'
@@ -503,31 +503,71 @@ function analyzeInternal<T extends boolean>(css: string, options: Options, useLo
503503 let value = node . value as CSSNode
504504
505505 let { text } = value
506- let loc = wallaceLoc ( value )
506+ let valueLoc = wallaceLoc ( value )
507507 let complexity = 1
508508
509509 // auto, inherit, initial, etc.
510510 if ( keywords . has ( text ) ) {
511- valueKeywords . p ( text , loc )
511+ valueKeywords . p ( text , valueLoc )
512512 valueComplexities . push ( complexity )
513513 return
514514 }
515515
516+ //#region VALUE COMPLEXITY
516517 // i.e. `background-image: -webkit-linear-gradient()`
517518 if ( isValuePrefixed ( value ) ) {
518- vendorPrefixedValues . p ( value . text , loc )
519+ vendorPrefixedValues . p ( value . text , valueLoc )
519520 complexity ++
520521 }
521522
522523 // i.e. `property: value\9`
523524 if ( isIe9Hack ( value ) ) {
524- valueBrowserhacks . p ( text , loc )
525+ valueBrowserhacks . p ( text , valueLoc )
525526 complexity ++
526527 }
528+ //#endregion VALUE COMPLEXITY
527529
528530 // TODO: should shorthands be counted towards complexity?
529531 valueComplexities . push ( complexity )
530532
533+ // Process properties first that don't have colors,
534+ // so we can avoid further walking them;
535+ if (
536+ isProperty ( 'margin' , property ) ||
537+ isProperty ( 'margin-block' , property ) ||
538+ isProperty ( 'margin-inline' , property ) ||
539+ isProperty ( 'margin-top' , property ) ||
540+ isProperty ( 'margin-right' , property ) ||
541+ isProperty ( 'margin-bottom' , property ) ||
542+ isProperty ( 'margin-left' , property ) ||
543+ isProperty ( 'padding' , property ) ||
544+ isProperty ( 'padding-block' , property ) ||
545+ isProperty ( 'padding-inline' , property ) ||
546+ isProperty ( 'padding-top' , property ) ||
547+ isProperty ( 'padding-right' , property ) ||
548+ isProperty ( 'padding-bottom' , property ) ||
549+ isProperty ( 'padding-left' , property )
550+ ) {
551+ if ( isValueReset ( value ) ) {
552+ resets . p ( property , valueLoc )
553+ }
554+ } else if ( isProperty ( 'z-index' , property ) ) {
555+ zindex . p ( value . text , valueLoc )
556+ return SKIP
557+ } else if ( isProperty ( 'font' , property ) ) {
558+ // TODO: implement
559+ } else if ( isProperty ( 'font-size' , property ) ) {
560+ if ( ! SYSTEM_FONTS . has ( value . text ) ) {
561+ fontSizes . p ( value . text , valueLoc )
562+ }
563+ } else if ( isProperty ( 'font-family' , property ) ) {
564+ if ( ! SYSTEM_FONTS . has ( value . text ) ) {
565+ fontFamilies . p ( value . text , valueLoc )
566+ }
567+ } else if ( isProperty ( 'line-height' , property ) ) {
568+ lineHeights . p ( value . text , valueLoc )
569+ }
570+
531571 wallaceWalk2 ( value , ( valueNode ) => {
532572 if ( valueNode . type_name === 'Dimension' ) {
533573 let unit = valueNode . unit !
@@ -611,7 +651,7 @@ function analyzeInternal<T extends boolean>(css: string, options: Options, useLo
611651 let loc = node . loc !
612652
613653 if ( isValueKeyword ( node ) ) {
614- valueComplexities . push ( 1 )
654+ // valueComplexities.push(1)
615655 break
616656 }
617657
@@ -638,12 +678,12 @@ function analyzeInternal<T extends boolean>(css: string, options: Options, useLo
638678 isProperty ( 'padding-bottom' , property ) ||
639679 isProperty ( 'padding-left' , property )
640680 ) {
641- if ( isValueReset ( node ) ) {
642- resets . p ( property , declaration . loc ! )
643- }
681+ // if (isValueReset(node)) {
682+ // resets.p(property, declaration.loc!)
683+ // }
644684 } else if ( isProperty ( 'z-index' , property ) ) {
645- zindex . p ( stringifyNode ( node ) , loc )
646- return this . skip
685+ // zindex.p(stringifyNode(node), loc)
686+ // return this.skip
647687 } else if ( isProperty ( 'font' , property ) ) {
648688 if ( isSystemFont ( node ) ) return
649689
@@ -672,17 +712,17 @@ function analyzeInternal<T extends boolean>(css: string, options: Options, useLo
672712
673713 break
674714 } else if ( isProperty ( 'font-size' , property ) ) {
675- if ( ! isSystemFont ( node ) ) {
676- fontSizes . p ( stringifyNode ( node ) , loc )
677- }
715+ // if (!isSystemFont(node)) {
716+ // fontSizes.p(stringifyNode(node), loc)
717+ // }
678718 break
679719 } else if ( isProperty ( 'font-family' , property ) ) {
680- if ( ! isSystemFont ( node ) ) {
681- fontFamilies . p ( stringifyNode ( node ) , loc )
682- }
720+ // if (!isSystemFont(node)) {
721+ // fontFamilies.p(stringifyNode(node), loc)
722+ // }
683723 break
684724 } else if ( isProperty ( 'line-height' , property ) ) {
685- lineHeights . p ( stringifyNode ( node ) , loc )
725+ // lineHeights.p(stringifyNode(node), loc)
686726 } else if ( isProperty ( 'transition' , property ) || isProperty ( 'animation' , property ) ) {
687727 analyzeAnimation ( children , function ( item : { type : string ; value : CssNode } ) {
688728 if ( item . type === 'fn' ) {
0 commit comments