Skip to content

Commit

Permalink
fix(transition): fix cancel leave regression (#5974)
Browse files Browse the repository at this point in the history
fix #5973
  • Loading branch information
edison1105 authored May 23, 2022
1 parent a0c5776 commit dddbd96
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/runtime-dom/src/components/Transition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand All @@ -234,7 +236,7 @@ export function resolveTransitionProps(
forceReflow()
addTransitionClass(el, leaveActiveClass)
nextFrame(() => {
if (!isLeaving) {
if (!el._isLeaving) {
// cancelled
return
}
Expand Down

0 comments on commit dddbd96

Please sign in to comment.