refactor: use markRaw instead of internal flag check

This commit is contained in:
Evan You 2021-06-11 18:42:57 -04:00
parent b228abb72f
commit 056ef2a7d2
2 changed files with 3 additions and 8 deletions

View File

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

View File

@ -18,7 +18,6 @@ import {
ReactiveEffect, ReactiveEffect,
toRaw, toRaw,
shallowReadonly, shallowReadonly,
ReactiveFlags,
track, track,
TrackOpTypes, TrackOpTypes,
ShallowUnwrapRef, ShallowUnwrapRef,
@ -268,11 +267,6 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
appContext appContext
} = instance } = 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 // for internal formatters to know that this is a Vue instance
if (__DEV__ && key === '__isVue') { if (__DEV__ && key === '__isVue') {
return true return true