]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
refactor(runtime-core): check `props` rather than `propsOptions[0]` (#13514)
authorskirtle <65301168+skirtles-code@users.noreply.github.com>
Mon, 24 Nov 2025 06:38:03 +0000 (06:38 +0000)
committerGitHub <noreply@github.com>
Mon, 24 Nov 2025 06:38:03 +0000 (14:38 +0800)
packages/runtime-core/src/componentPublicInstance.ts

index 57d784c0e087896a846e6b20503d90e02df5670a..a334b487dfd9d37cea71553452fc10d9a45feb75 100644 (file)
@@ -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) ||