Przeglądaj źródła

perf: instance public proxy should never be observed

Evan You 6 lat temu
rodzic
commit
11f38d8a85
1 zmienionych plików z 4 dodań i 2 usunięć
  1. 4 2
      packages/runtime-core/src/component.ts

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

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