Skip to content

Commit

Permalink
Speed up CSS math function check (#12215)
Browse files Browse the repository at this point in the history
* perf(cssMathFnRE): Dynamically create regular rules

* Cleanup code

---------

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
  • Loading branch information
Simon-He95 and thecrypticace authored Oct 17, 2023
1 parent 44fb67b commit e9ca7ab
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/util/dataTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import { parseBoxShadowValue } from './parseBoxShadowValue'
import { splitAtTopLevelOnly } from './splitAtTopLevelOnly'

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

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

function isCSSFunction(value) {
return cssFunctions.some((fn) => new RegExp(`^${fn}\\(.*\\)`).test(value))
return IS_CSS_FN.test(value)
}

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

0 comments on commit e9ca7ab

Please sign in to comment.