fix: do not warn Symbol.unscopables access

This commit is contained in:
Ilya Golovin 2024-07-02 15:17:22 +03:00
parent ae97e50538
commit ef292a8d90
2 changed files with 10 additions and 3 deletions

View File

@ -443,7 +443,7 @@ describe('component: proxy', () => {
).not.toHaveBeenWarned() ).not.toHaveBeenWarned()
}) })
test('should allow symbol to access on render', () => { test('should not warn Symbol.unscopables access on render', () => {
const Comp = { const Comp = {
render() { render() {
if ((this as any)[Symbol.unscopables]) { if ((this as any)[Symbol.unscopables]) {
@ -460,7 +460,7 @@ describe('component: proxy', () => {
`Property ${JSON.stringify( `Property ${JSON.stringify(
Symbol.unscopables, Symbol.unscopables,
)} was accessed during render ` + `but is not defined on instance.`, )} was accessed during render ` + `but is not defined on instance.`,
).toHaveBeenWarned() ).not.toHaveBeenWarned()
}) })
test('should prevent mutating script setup bindings', () => { test('should prevent mutating script setup bindings', () => {

View File

@ -308,7 +308,14 @@ const hasSetupBinding = (state: Data, key: string) =>
state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key) state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key)
export const PublicInstanceProxyHandlers: ProxyHandler<any> = { export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
get({ _: instance }: ComponentRenderContext, key: string) { get(
{ _: instance }: ComponentRenderContext,
key: string | typeof Symbol.unscopables,
) {
if (key === Symbol.unscopables) {
return
}
if (key === ReactiveFlags.SKIP) { if (key === ReactiveFlags.SKIP) {
return true return true
} }