mirror of https://github.com/vuejs/core.git
refactor(runtime-core): check `props` rather than `propsOptions[0]` (#13514)
This commit is contained in:
parent
2214f7ab29
commit
5af3dd9b45
|
|
@ -430,7 +430,6 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
|
|||
// is the multiple hasOwn() calls. It's much faster to do a simple property
|
||||
// access on a plain object, so we use an accessCache object (with null
|
||||
// prototype) to memoize what access type a key corresponds to.
|
||||
let normalizedProps
|
||||
if (key[0] !== '$') {
|
||||
const n = accessCache![key]
|
||||
if (n !== undefined) {
|
||||
|
|
@ -455,12 +454,7 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
|
|||
) {
|
||||
accessCache![key] = AccessTypes.DATA
|
||||
return data[key]
|
||||
} else if (
|
||||
// only cache other properties when instance has declared (thus stable)
|
||||
// props
|
||||
(normalizedProps = instance.propsOptions[0]) &&
|
||||
hasOwn(normalizedProps, key)
|
||||
) {
|
||||
} else if (hasOwn(props, key)) {
|
||||
accessCache![key] = AccessTypes.PROPS
|
||||
return props![key]
|
||||
} else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
|
||||
|
|
@ -583,11 +577,11 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
|
|||
|
||||
has(
|
||||
{
|
||||
_: { data, setupState, accessCache, ctx, appContext, propsOptions, type },
|
||||
_: { data, setupState, accessCache, ctx, appContext, props, type },
|
||||
}: ComponentRenderContext,
|
||||
key: string,
|
||||
) {
|
||||
let normalizedProps, cssModules
|
||||
let cssModules
|
||||
return !!(
|
||||
accessCache![key] ||
|
||||
(__FEATURE_OPTIONS_API__ &&
|
||||
|
|
@ -595,7 +589,7 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
|
|||
key[0] !== '$' &&
|
||||
hasOwn(data, key)) ||
|
||||
hasSetupBinding(setupState, key) ||
|
||||
((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
|
||||
hasOwn(props, key) ||
|
||||
hasOwn(ctx, key) ||
|
||||
hasOwn(publicPropertiesMap, key) ||
|
||||
hasOwn(appContext.config.globalProperties, key) ||
|
||||
|
|
|
|||
Loading…
Reference in New Issue