mirror of https://github.com/vuejs/core.git
fix: do not warn Symbol.unscopables access
This commit is contained in:
parent
ae97e50538
commit
ef292a8d90
|
@ -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', () => {
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue