diff --git a/packages/runtime-core/__tests__/componentPublicInstance.spec.ts b/packages/runtime-core/__tests__/componentPublicInstance.spec.ts index 37c228a5104..fb194c8b457 100644 --- a/packages/runtime-core/__tests__/componentPublicInstance.spec.ts +++ b/packages/runtime-core/__tests__/componentPublicInstance.spec.ts @@ -443,7 +443,7 @@ describe('component: proxy', () => { ).not.toHaveBeenWarned() }) - test('should allow symbol to access on render', () => { + test('should not warn Symbol.unscopables access on render', () => { const Comp = { render() { if ((this as any)[Symbol.unscopables]) { @@ -460,7 +460,7 @@ describe('component: proxy', () => { `Property ${JSON.stringify( Symbol.unscopables, )} was accessed during render ` + `but is not defined on instance.`, - ).toHaveBeenWarned() + ).not.toHaveBeenWarned() }) test('should prevent mutating script setup bindings', () => { diff --git a/packages/runtime-core/src/componentPublicInstance.ts b/packages/runtime-core/src/componentPublicInstance.ts index e9e7770ebd9..6803c51dd8e 100644 --- a/packages/runtime-core/src/componentPublicInstance.ts +++ b/packages/runtime-core/src/componentPublicInstance.ts @@ -411,7 +411,14 @@ const hasSetupBinding = (state: Data, key: string) => state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key) export const PublicInstanceProxyHandlers: ProxyHandler = { - get({ _: instance }: ComponentRenderContext, key: string) { + get( + { _: instance }: ComponentRenderContext, + key: string | typeof Symbol.unscopables, + ) { + if (key === Symbol.unscopables) { + return + } + if (key === ReactiveFlags.SKIP) { return true }