refactor(runtime-core): check `props` rather than `propsOptions[0]` (#13514)

This commit is contained in:
skirtle 2025-11-24 06:38:03 +00:00 committed by GitHub
parent 2214f7ab29
commit 5af3dd9b45
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 10 deletions

View File

@ -430,7 +430,6 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
// is the multiple hasOwn() calls. It's much faster to do a simple property // 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 // access on a plain object, so we use an accessCache object (with null
// prototype) to memoize what access type a key corresponds to. // prototype) to memoize what access type a key corresponds to.
let normalizedProps
if (key[0] !== '$') { if (key[0] !== '$') {
const n = accessCache![key] const n = accessCache![key]
if (n !== undefined) { if (n !== undefined) {
@ -455,12 +454,7 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
) { ) {
accessCache![key] = AccessTypes.DATA accessCache![key] = AccessTypes.DATA
return data[key] return data[key]
} else if ( } else if (hasOwn(props, key)) {
// only cache other properties when instance has declared (thus stable)
// props
(normalizedProps = instance.propsOptions[0]) &&
hasOwn(normalizedProps, key)
) {
accessCache![key] = AccessTypes.PROPS accessCache![key] = AccessTypes.PROPS
return props![key] return props![key]
} else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) { } else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
@ -583,11 +577,11 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
has( has(
{ {
_: { data, setupState, accessCache, ctx, appContext, propsOptions, type }, _: { data, setupState, accessCache, ctx, appContext, props, type },
}: ComponentRenderContext, }: ComponentRenderContext,
key: string, key: string,
) { ) {
let normalizedProps, cssModules let cssModules
return !!( return !!(
accessCache![key] || accessCache![key] ||
(__FEATURE_OPTIONS_API__ && (__FEATURE_OPTIONS_API__ &&
@ -595,7 +589,7 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
key[0] !== '$' && key[0] !== '$' &&
hasOwn(data, key)) || hasOwn(data, key)) ||
hasSetupBinding(setupState, key) || hasSetupBinding(setupState, key) ||
((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) || hasOwn(props, key) ||
hasOwn(ctx, key) || hasOwn(ctx, key) ||
hasOwn(publicPropertiesMap, key) || hasOwn(publicPropertiesMap, key) ||
hasOwn(appContext.config.globalProperties, key) || hasOwn(appContext.config.globalProperties, key) ||