Skip to content

Commit e9ca7ab

Browse files
Speed up CSS math function check (#12215)
* perf(cssMathFnRE): Dynamically create regular rules * Cleanup code --------- Co-authored-by: Jordan Pittman <[email protected]>
1 parent 44fb67b commit e9ca7ab

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/util/dataTypes.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import { parseBoxShadowValue } from './parseBoxShadowValue'
33
import { splitAtTopLevelOnly } from './splitAtTopLevelOnly'
44

55
let cssFunctions = ['min', 'max', 'clamp', 'calc']
6+
let IS_CSS_FN = new RegExp(`^(${cssFunctions.join('|')})\\(.*\\)`)
67

78
// Ref: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Types
89

910
function isCSSFunction(value) {
10-
return cssFunctions.some((fn) => new RegExp(`^${fn}\\(.*\\)`).test(value))
11+
return IS_CSS_FN.test(value)
1112
}
1213

1314
// This is not a data type, but rather a function that can normalize the

0 commit comments

Comments
 (0)