Sfoglia il codice sorgente

refactor: use markRaw instead of internal flag check

Evan You 5 anni fa
parent
commit
056ef2a7d2

+ 3 - 2
packages/runtime-core/src/component.ts

@@ -4,7 +4,8 @@ import {
   pauseTracking,
   resetTracking,
   shallowReadonly,
-  proxyRefs
+  proxyRefs,
+  markRaw
 } from '@vue/reactivity'
 import {
   ComponentPublicInstance,
@@ -597,7 +598,7 @@ function setupStatefulComponent(
   instance.accessCache = Object.create(null)
   // 1. create public instance / render proxy
   // also mark it raw so it's never observed
-  instance.proxy = new Proxy(instance.ctx, PublicInstanceProxyHandlers)
+  instance.proxy = markRaw(new Proxy(instance.ctx, PublicInstanceProxyHandlers))
   if (__DEV__) {
     exposePropsOnRenderContext(instance)
   }

+ 0 - 6
packages/runtime-core/src/componentPublicInstance.ts

@@ -18,7 +18,6 @@ import {
   ReactiveEffect,
   toRaw,
   shallowReadonly,
-  ReactiveFlags,
   track,
   TrackOpTypes,
   ShallowUnwrapRef,
@@ -268,11 +267,6 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
       appContext
     } = instance
 
-    // let @vue/reactivity know it should never observe Vue public instances.
-    if (key === ReactiveFlags.SKIP) {
-      return true
-    }
-
     // for internal formatters to know that this is a Vue instance
     if (__DEV__ && key === '__isVue') {
       return true