Skip to content

Commit 4f023d4

Browse files
committed
perf(preset-mini): deprecate regex for search css variables
1 parent ba06c02 commit 4f023d4

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

packages-presets/preset-mini/src/_utils/utilities.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { toArray } from '@unocss/core'
55
import { colorOpacityToString, colorToString, getStringComponent, getStringComponents, parseCssColor } from '@unocss/rule-utils'
66
import { h } from './handlers'
77
import { bracketTypeRe, numberWithUnitRE, splitComma } from './handlers/regex'
8-
import { cssMathFnRE, cssVarFnRE, directionMap, globalKeywords, xyzArray, xyzMap } from './mappings'
8+
import { cssMathFnRE, directionMap, globalKeywords, xyzArray, xyzMap } from './mappings'
99

1010
export const CONTROL_MINI_NO_NEGATIVE = '$$mini-no-negative'
1111

@@ -252,7 +252,7 @@ export function colorableShadows(shadows: string | string[], colorVar: string) {
252252
if (color)
253253
colorVarValue = `, ${colorToString(color)}`
254254
}
255-
else if (lastComp && cssVarFnRE.test(lastComp)) {
255+
else if (lastComp && lastComp.startsWith('var(')) {
256256
const color = components.pop()!
257257
colorVarValue = `, ${color}`
258258
}

packages-presets/preset-wind4/src/utils/utilities.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { colorToString, getStringComponent, getStringComponents, isInterpolatedM
55
import { SpecialColorKey } from './constant'
66
import { h } from './handlers'
77
import { bracketTypeRe, numberWithUnitRE } from './handlers/regex'
8-
import { cssMathFnRE, cssVarFnRE, directionMap, globalKeywords } from './mappings'
8+
import { cssMathFnRE, directionMap, globalKeywords } from './mappings'
99
import { detectThemeValue, generateThemeVariable, propertyTracking, themeTracking } from './track'
1010

1111
// #region Number Resolver
@@ -329,7 +329,7 @@ export function colorableShadows(shadows: string | string[], colorVar: string, a
329329
if (color)
330330
colorVarValue = colorToString(color)
331331
}
332-
else if (lastComp && cssVarFnRE.test(lastComp)) {
332+
else if (lastComp && lastComp.startsWith('var(')) {
333333
const color = components.pop()
334334
if (color)
335335
colorVarValue = color

0 commit comments

Comments
 (0)