Browse Source

refactor(runtime-core): check feature flag when forwarding `data` properties (#13966)

skirtle 5 months ago
parent
commit
b8aab3d209
1 changed files with 14 additions and 3 deletions
  1. 14 3
      packages/runtime-core/src/componentPublicInstance.ts

+ 14 - 3
packages/runtime-core/src/componentPublicInstance.ts

@@ -448,7 +448,11 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
       } else if (hasSetupBinding(setupState, key)) {
       } else if (hasSetupBinding(setupState, key)) {
         accessCache![key] = AccessTypes.SETUP
         accessCache![key] = AccessTypes.SETUP
         return setupState[key]
         return setupState[key]
-      } else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
+      } else if (
+        __FEATURE_OPTIONS_API__ &&
+        data !== EMPTY_OBJ &&
+        hasOwn(data, key)
+      ) {
         accessCache![key] = AccessTypes.DATA
         accessCache![key] = AccessTypes.DATA
         return data[key]
         return data[key]
       } else if (
       } else if (
@@ -545,7 +549,11 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
     ) {
     ) {
       warn(`Cannot mutate <script setup> binding "${key}" from Options API.`)
       warn(`Cannot mutate <script setup> binding "${key}" from Options API.`)
       return false
       return false
-    } else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
+    } else if (
+      __FEATURE_OPTIONS_API__ &&
+      data !== EMPTY_OBJ &&
+      hasOwn(data, key)
+    ) {
       data[key] = value
       data[key] = value
       return true
       return true
     } else if (hasOwn(instance.props, key)) {
     } else if (hasOwn(instance.props, key)) {
@@ -582,7 +590,10 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
     let normalizedProps, cssModules
     let normalizedProps, cssModules
     return !!(
     return !!(
       accessCache![key] ||
       accessCache![key] ||
-      (data !== EMPTY_OBJ && key[0] !== '$' && hasOwn(data, key)) ||
+      (__FEATURE_OPTIONS_API__ &&
+        data !== EMPTY_OBJ &&
+        key[0] !== '$' &&
+        hasOwn(data, key)) ||
       hasSetupBinding(setupState, key) ||
       hasSetupBinding(setupState, key) ||
       ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
       ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
       hasOwn(ctx, key) ||
       hasOwn(ctx, key) ||