fix(Teleport): component with multi roots should be removed when unmounted (#3157)

fix #3156
This commit is contained in:
HcySunYang
2021-03-25 23:02:50 +08:00
committed by GitHub
parent 0a583d5ca2
commit 776951315d
3 changed files with 40 additions and 4 deletions

View File

@@ -147,6 +147,26 @@ describe('renderer: teleport', () => {
testUnmount({ to: null, disabled: true })
})
test('component with multi roots should be removed when unmounted', () => {
const target = nodeOps.createElement('div')
const root = nodeOps.createElement('div')
const Comp = {
render() {
return [h('p'), h('p')]
}
}
render(
h(() => [h(Teleport, { to: target }, h(Comp)), h('div', 'root')]),
root
)
expect(serializeInner(target)).toMatchInlineSnapshot(`"<p></p><p></p>"`)
render(null, root)
expect(serializeInner(target)).toBe('')
})
test('multiple teleport with same target', () => {
const target = nodeOps.createElement('div')
const root = nodeOps.createElement('div')