diff --git a/packages/runtime-core/__tests__/componentProxy.spec.ts b/packages/runtime-core/__tests__/componentProxy.spec.ts index 4a4b56a8473..e53cb20e412 100644 --- a/packages/runtime-core/__tests__/componentProxy.spec.ts +++ b/packages/runtime-core/__tests__/componentProxy.spec.ts @@ -240,6 +240,6 @@ describe('component: proxy', () => { `Property ${JSON.stringify( Symbol.unscopables )} was accessed during render ` + `but is not defined on instance.` - ).toHaveBeenWarned() + ).not.toHaveBeenWarned() }) }) diff --git a/packages/runtime-core/src/componentPublicInstance.ts b/packages/runtime-core/src/componentPublicInstance.ts index 1e62f8b16c5..d67600f0c6f 100644 --- a/packages/runtime-core/src/componentPublicInstance.ts +++ b/packages/runtime-core/src/componentPublicInstance.ts @@ -241,7 +241,7 @@ export interface ComponentRenderContext { } export const PublicInstanceProxyHandlers: ProxyHandler = { - get({ _: instance }: ComponentRenderContext, key: string) { + get({ _: instance }: ComponentRenderContext, keyOrSymbol: string | symbol) { const { ctx, setupState, @@ -251,12 +251,18 @@ export const PublicInstanceProxyHandlers: ProxyHandler = { type, appContext } = instance + const key = keyOrSymbol as string // let @vue/reactivity know it should never observe Vue public instances. if (key === ReactiveFlags.SKIP) { return true } + // this seems to come from the `with(_ctx) {}` used in render functions + if (keyOrSymbol === Symbol.unscopables) { + return undefined + } + // for internal formatters to know that this is a Vue instance if (__DEV__ && key === '__isVue') { return true