Refactor length function to utilize a pre-compiled RegExp (#12251)
* Refactor length function to utilize a pre-compiled RegExp * Update dataTypes.js
This commit is contained in:
parent
4e1a26aad0
commit
bcfb38d5f9
1 changed files with 2 additions and 5 deletions
|
|
@ -173,12 +173,9 @@ let lengthUnits = [
|
|||
'cqmax',
|
||||
]
|
||||
let lengthUnitsPattern = `(?:${lengthUnits.join('|')})`
|
||||
let lengthRegExp = new RegExp(`^[+-]?[0-9]*\.?[0-9]+(?:[eE][+-]?[0-9]+)?${lengthUnitsPattern}$`)
|
||||
export function length(value) {
|
||||
return (
|
||||
value === '0' ||
|
||||
new RegExp(`^[+-]?[0-9]*\.?[0-9]+(?:[eE][+-]?[0-9]+)?${lengthUnitsPattern}$`).test(value) ||
|
||||
isCSSFunction(value)
|
||||
)
|
||||
return value === '0' || lengthRegExp.test(value) || isCSSFunction(value)
|
||||
}
|
||||
|
||||
let lineWidths = new Set(['thin', 'medium', 'thick'])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue