Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(runtime-core): allow calling hasOwnProperty on proxy #4215

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions packages/runtime-core/__tests__/componentPublicInstance.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,22 @@ describe('component: proxy', () => {
])
})

test('allow calling hasOwnProperty', () => {
let instanceProxy: any
const Comp = {
render() {},
mounted() {
instanceProxy = this
}
}

const app = createApp(Comp)

app.mount(nodeOps.createElement('div'))

expect(instanceProxy.hasOwnProperty).not.toBeNull()
})

// #864
test('should not warn declared but absent props', () => {
const Comp = {
Expand Down
2 changes: 2 additions & 0 deletions packages/runtime-core/src/componentPublicInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,8 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
`but is not defined on instance.`
)
}
} else if (key === 'hasOwnProperty') {
return ctx.hasOwnProperty
}
},

Expand Down