fix(runtime-core): prevent self-injection (#2424)

fix #2400
This commit is contained in:
Hunter
2020-10-20 08:45:48 +08:00
committed by GitHub
parent 314ab2c7c5
commit 111d04f119
2 changed files with 24 additions and 2 deletions

View File

@@ -303,4 +303,19 @@ describe('api: provide/inject', () => {
render(h(Provider), root)
expect(`injection "foo" not found.`).not.toHaveBeenWarned()
})
// #2400
it('should not self-inject', () => {
const Comp = {
setup() {
provide('foo', 'foo')
const injection = inject('foo', null)
return () => injection
}
}
const root = nodeOps.createElement('div')
render(h(Comp), root)
expect(serialize(root)).toBe(`<div><!----></div>`)
})
})