fix(teleport): targetAnchor should also be removed when unmounted (#2870)
* fix(teleport): targetAnchor should also be removed when unmounted * fix(teleport): targetAnchor should also be removed when unmounted
This commit is contained in:
@@ -218,13 +218,22 @@ export const TeleportImpl = {
|
||||
|
||||
remove(
|
||||
vnode: VNode,
|
||||
{ r: remove, o: { remove: hostRemove } }: RendererInternals
|
||||
{ r: remove, o: { remove: hostRemove } }: RendererInternals,
|
||||
doRemove: Boolean
|
||||
) {
|
||||
const { shapeFlag, children, anchor } = vnode
|
||||
hostRemove(anchor!)
|
||||
if (shapeFlag & ShapeFlags.ARRAY_CHILDREN) {
|
||||
for (let i = 0; i < (children as VNode[]).length; i++) {
|
||||
remove((children as VNode[])[i])
|
||||
const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode
|
||||
|
||||
if (target) {
|
||||
hostRemove(targetAnchor!)
|
||||
}
|
||||
|
||||
// an unmounted teleport should always remove its children if not disabled
|
||||
if (doRemove || !isTeleportDisabled(props)) {
|
||||
hostRemove(anchor!)
|
||||
if (shapeFlag & ShapeFlags.ARRAY_CHILDREN) {
|
||||
for (let i = 0; i < (children as VNode[]).length; i++) {
|
||||
remove((children as VNode[])[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -57,11 +57,7 @@ import {
|
||||
queueEffectWithSuspense,
|
||||
SuspenseImpl
|
||||
} from './components/Suspense'
|
||||
import {
|
||||
isTeleportDisabled,
|
||||
TeleportImpl,
|
||||
TeleportVNode
|
||||
} from './components/Teleport'
|
||||
import { TeleportImpl, TeleportVNode } from './components/Teleport'
|
||||
import { isKeepAlive, KeepAliveContext } from './components/KeepAlive'
|
||||
import { registerHMR, unregisterHMR, isHmrUpdating } from './hmr'
|
||||
import {
|
||||
@@ -2111,12 +2107,8 @@ function baseCreateRenderer(
|
||||
unmountChildren(children as VNode[], parentComponent, parentSuspense)
|
||||
}
|
||||
|
||||
// an unmounted teleport should always remove its children if not disabled
|
||||
if (
|
||||
shapeFlag & ShapeFlags.TELEPORT &&
|
||||
(doRemove || !isTeleportDisabled(vnode.props))
|
||||
) {
|
||||
;(vnode.type as typeof TeleportImpl).remove(vnode, internals)
|
||||
if (shapeFlag & ShapeFlags.TELEPORT) {
|
||||
;(vnode.type as typeof TeleportImpl).remove(vnode, internals, doRemove)
|
||||
}
|
||||
|
||||
if (doRemove) {
|
||||
|
||||
Reference in New Issue
Block a user