mirror of https://github.com/vuejs/core.git
fix(Transition): fix transition memory leak edge case (#12182)
close #12181
This commit is contained in:
parent
4aeff318bd
commit
660132df6c
|
@ -198,8 +198,7 @@ const BaseTransitionImpl: ComponentOptions = {
|
|||
setTransitionHooks(innerChild, enterHooks)
|
||||
}
|
||||
|
||||
const oldChild = instance.subTree
|
||||
const oldInnerChild = oldChild && getInnerChild(oldChild)
|
||||
let oldInnerChild = instance.subTree && getInnerChild(instance.subTree)
|
||||
|
||||
// handle mode
|
||||
if (
|
||||
|
@ -208,7 +207,7 @@ const BaseTransitionImpl: ComponentOptions = {
|
|||
!isSameVNodeType(innerChild, oldInnerChild) &&
|
||||
recursiveGetSubtree(instance).type !== Comment
|
||||
) {
|
||||
const leavingHooks = resolveTransitionHooks(
|
||||
let leavingHooks = resolveTransitionHooks(
|
||||
oldInnerChild,
|
||||
rawProps,
|
||||
state,
|
||||
|
@ -228,6 +227,7 @@ const BaseTransitionImpl: ComponentOptions = {
|
|||
instance.update()
|
||||
}
|
||||
delete leavingHooks.afterLeave
|
||||
oldInnerChild = undefined
|
||||
}
|
||||
return emptyPlaceholder(child)
|
||||
} else if (mode === 'in-out' && innerChild.type !== Comment) {
|
||||
|
@ -238,18 +238,27 @@ const BaseTransitionImpl: ComponentOptions = {
|
|||
) => {
|
||||
const leavingVNodesCache = getLeavingNodesForType(
|
||||
state,
|
||||
oldInnerChild,
|
||||
oldInnerChild!,
|
||||
)
|
||||
leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild
|
||||
leavingVNodesCache[String(oldInnerChild!.key)] = oldInnerChild!
|
||||
// early removal callback
|
||||
el[leaveCbKey] = () => {
|
||||
earlyRemove()
|
||||
el[leaveCbKey] = undefined
|
||||
delete enterHooks.delayedLeave
|
||||
oldInnerChild = undefined
|
||||
}
|
||||
enterHooks.delayedLeave = delayedLeave
|
||||
enterHooks.delayedLeave = () => {
|
||||
delayedLeave()
|
||||
delete enterHooks.delayedLeave
|
||||
oldInnerChild = undefined
|
||||
}
|
||||
}
|
||||
} else {
|
||||
oldInnerChild = undefined
|
||||
}
|
||||
} else if (oldInnerChild) {
|
||||
oldInnerChild = undefined
|
||||
}
|
||||
|
||||
return child
|
||||
|
|
Loading…
Reference in New Issue