fix(runtime-core/teleport): ensure the nested teleport can be unmounted correctly (#3629)
fix #3623
This commit is contained in:
parent
201060717d
commit
4e3f82f683
@ -1,6 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
h,
|
h,
|
||||||
Fragment,
|
Fragment,
|
||||||
|
Teleport,
|
||||||
createVNode,
|
createVNode,
|
||||||
createCommentVNode,
|
createCommentVNode,
|
||||||
openBlock,
|
openBlock,
|
||||||
@ -578,6 +579,47 @@ describe('renderer: optimized mode', () => {
|
|||||||
expect(inner(root)).toBe('<div>World</div>')
|
expect(inner(root)).toBe('<div>World</div>')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
//#3623
|
||||||
|
test('nested teleport unmount need exit the optimization mode', () => {
|
||||||
|
const target = nodeOps.createElement('div')
|
||||||
|
const root = nodeOps.createElement('div')
|
||||||
|
|
||||||
|
render(
|
||||||
|
(openBlock(),
|
||||||
|
createBlock('div', null, [
|
||||||
|
(openBlock(),
|
||||||
|
createBlock(
|
||||||
|
Teleport as any,
|
||||||
|
{
|
||||||
|
to: target
|
||||||
|
},
|
||||||
|
[
|
||||||
|
createVNode('div', null, [
|
||||||
|
(openBlock(),
|
||||||
|
createBlock(
|
||||||
|
Teleport as any,
|
||||||
|
{
|
||||||
|
to: target
|
||||||
|
},
|
||||||
|
[createVNode('div', null, 'foo')]
|
||||||
|
))
|
||||||
|
])
|
||||||
|
]
|
||||||
|
))
|
||||||
|
])),
|
||||||
|
root
|
||||||
|
)
|
||||||
|
expect(inner(target)).toMatchInlineSnapshot(
|
||||||
|
`"<div><!--teleport start--><!--teleport end--></div><div>foo</div>"`
|
||||||
|
)
|
||||||
|
expect(inner(root)).toMatchInlineSnapshot(
|
||||||
|
`"<div><!--teleport start--><!--teleport end--></div>"`
|
||||||
|
)
|
||||||
|
|
||||||
|
render(null, root)
|
||||||
|
expect(inner(target)).toBe('')
|
||||||
|
})
|
||||||
|
|
||||||
// #3548
|
// #3548
|
||||||
test('should not track dynamic children when the user calls a compiled slot inside template expression', () => {
|
test('should not track dynamic children when the user calls a compiled slot inside template expression', () => {
|
||||||
const Comp = {
|
const Comp = {
|
||||||
|
@ -243,12 +243,13 @@ export const TeleportImpl = {
|
|||||||
hostRemove(anchor!)
|
hostRemove(anchor!)
|
||||||
if (shapeFlag & ShapeFlags.ARRAY_CHILDREN) {
|
if (shapeFlag & ShapeFlags.ARRAY_CHILDREN) {
|
||||||
for (let i = 0; i < (children as VNode[]).length; i++) {
|
for (let i = 0; i < (children as VNode[]).length; i++) {
|
||||||
|
const child = (children as VNode[])[i]
|
||||||
unmount(
|
unmount(
|
||||||
(children as VNode[])[i],
|
child,
|
||||||
parentComponent,
|
parentComponent,
|
||||||
parentSuspense,
|
parentSuspense,
|
||||||
true,
|
true,
|
||||||
optimized
|
!!child.dynamicChildren
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user