perf(runtime-core): use makeMap
instead of RE
(#350)
This commit is contained in:
parent
e34d2bd853
commit
9dcbf17f3a
@ -11,7 +11,8 @@ import {
|
|||||||
isReservedProp,
|
isReservedProp,
|
||||||
hasOwn,
|
hasOwn,
|
||||||
toTypeString,
|
toTypeString,
|
||||||
PatchFlags
|
PatchFlags,
|
||||||
|
makeMap
|
||||||
} from '@vue/shared'
|
} from '@vue/shared'
|
||||||
import { warn } from './warning'
|
import { warn } from './warning'
|
||||||
import { Data, ComponentInternalInstance } from './component'
|
import { Data, ComponentInternalInstance } from './component'
|
||||||
@ -315,12 +316,14 @@ function validateProp(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/
|
const isSimpleType = /*#__PURE__*/ makeMap(
|
||||||
|
'String,Number,Boolean,Function,Symbol'
|
||||||
|
)
|
||||||
|
|
||||||
function assertType(value: unknown, type: PropConstructor): AssertionResult {
|
function assertType(value: unknown, type: PropConstructor): AssertionResult {
|
||||||
let valid
|
let valid
|
||||||
const expectedType = getType(type)
|
const expectedType = getType(type)
|
||||||
if (simpleCheckRE.test(expectedType)) {
|
if (isSimpleType(expectedType)) {
|
||||||
const t = typeof value
|
const t = typeof value
|
||||||
valid = t === expectedType.toLowerCase()
|
valid = t === expectedType.toLowerCase()
|
||||||
// for primitive wrapper objects
|
// for primitive wrapper objects
|
||||||
|
Loading…
x
Reference in New Issue
Block a user