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()
})
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', () => {

View File

@ -308,7 +308,14 @@ const hasSetupBinding = (state: Data, key: string) =>
state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key)
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) {
return true
}