fix(portal): portal should always remove its children when unmounted
This commit is contained in:
@@ -76,4 +76,21 @@ describe('renderer: portal', () => {
|
||||
|
||||
expect(serializeInner(target)).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('should remove children when unmounted', () => {
|
||||
const target = nodeOps.createElement('div')
|
||||
const root = nodeOps.createElement('div')
|
||||
|
||||
const Comp = defineComponent(() => () => [
|
||||
h(Portal, { target }, h('div', 'teleported')),
|
||||
h('div', 'root')
|
||||
])
|
||||
render(h(Comp), root)
|
||||
expect(serializeInner(target)).toMatchInlineSnapshot(
|
||||
`"<div>teleported</div>"`
|
||||
)
|
||||
|
||||
render(null, root)
|
||||
expect(serializeInner(target)).toBe('')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`renderer: portal should remove children when unmounted 1`] = `"<div>teleported</div>"`;
|
||||
|
||||
exports[`renderer: portal should update children 1`] = `"<div>teleported</div>"`;
|
||||
|
||||
exports[`renderer: portal should update children 2`] = `""`;
|
||||
|
||||
Reference in New Issue
Block a user