fix(transition): fix cancel leave regression (#5974)

fix #5973
This commit is contained in:
edison 2022-05-23 08:02:15 +08:00 committed by GitHub
parent a0c577692f
commit dddbd96dfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -174,9 +174,11 @@ export function resolveTransitionProps(
done && done()
}
let isLeaving = false
const finishLeave = (el: Element, done?: () => void) => {
isLeaving = false
const finishLeave = (
el: Element & { _isLeaving?: boolean },
done?: () => void
) => {
el._isLeaving = false
removeTransitionClass(el, leaveFromClass)
removeTransitionClass(el, leaveToClass)
removeTransitionClass(el, leaveActiveClass)
@ -223,8 +225,8 @@ export function resolveTransitionProps(
},
onEnter: makeEnterHook(false),
onAppear: makeEnterHook(true),
onLeave(el, done) {
isLeaving = true
onLeave(el: Element & { _isLeaving?: boolean }, done) {
el._isLeaving = true
const resolve = () => finishLeave(el, done)
addTransitionClass(el, leaveFromClass)
if (__COMPAT__ && legacyClassEnabled) {
@ -234,7 +236,7 @@ export function resolveTransitionProps(
forceReflow()
addTransitionClass(el, leaveActiveClass)
nextFrame(() => {
if (!isLeaving) {
if (!el._isLeaving) {
// cancelled
return
}