Skip to content

Commit

Permalink
fix(runtime-core): error when key is Symbol.unscopable
Browse files Browse the repository at this point in the history
  • Loading branch information
rhengles committed Dec 29, 2020
1 parent e5a5a2c commit bddc3c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/runtime-core/__tests__/componentProxy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
})
8 changes: 7 additions & 1 deletion packages/runtime-core/src/componentPublicInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export interface ComponentRenderContext {
}

export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
get({ _: instance }: ComponentRenderContext, key: string) {
get({ _: instance }: ComponentRenderContext, keyOrSymbol: string | symbol) {
const {
ctx,
setupState,
Expand All @@ -251,12 +251,18 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
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
Expand Down

0 comments on commit bddc3c0

Please sign in to comment.