Skip to content

Commit e7b0d93

Browse files
committed
refactor(runtime-core): check props rather than propsOptions[0]
1 parent 5f8314c commit e7b0d93

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

packages/runtime-core/src/componentPublicInstance.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,6 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
430430
// is the multiple hasOwn() calls. It's much faster to do a simple property
431431
// access on a plain object, so we use an accessCache object (with null
432432
// prototype) to memoize what access type a key corresponds to.
433-
let normalizedProps
434433
if (key[0] !== '$') {
435434
const n = accessCache![key]
436435
if (n !== undefined) {
@@ -451,12 +450,7 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
451450
} else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
452451
accessCache![key] = AccessTypes.DATA
453452
return data[key]
454-
} else if (
455-
// only cache other properties when instance has declared (thus stable)
456-
// props
457-
(normalizedProps = instance.propsOptions[0]) &&
458-
hasOwn(normalizedProps, key)
459-
) {
453+
} else if (hasOwn(props, key)) {
460454
accessCache![key] = AccessTypes.PROPS
461455
return props![key]
462456
} else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
@@ -575,16 +569,15 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
575569

576570
has(
577571
{
578-
_: { data, setupState, accessCache, ctx, appContext, propsOptions },
572+
_: { data, setupState, accessCache, ctx, appContext, props },
579573
}: ComponentRenderContext,
580574
key: string,
581575
) {
582-
let normalizedProps
583576
return (
584577
!!accessCache![key] ||
585578
(data !== EMPTY_OBJ && hasOwn(data, key)) ||
586579
hasSetupBinding(setupState, key) ||
587-
((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
580+
hasOwn(props, key) ||
588581
hasOwn(ctx, key) ||
589582
hasOwn(publicPropertiesMap, key) ||
590583
hasOwn(appContext.config.globalProperties, key)

0 commit comments

Comments
 (0)