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