Skip to content

Commit 3c7dbdb

Browse files
author
Guillaume Chau
committed
fix(transition): Don't add 'to' class if transition is cancelled
When a transition is cancelled before the next frame, the `v-enter-to` or `v-leave-to` class was still added to the element. fix vuejs#7390
1 parent 0959b17 commit 3c7dbdb

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/platforms/web/runtime/modules/transition.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,15 @@ export function enter (vnode: VNodeWithData, toggleDisplay: ?() => void) {
149149
addTransitionClass(el, startClass)
150150
addTransitionClass(el, activeClass)
151151
nextFrame(() => {
152-
addTransitionClass(el, toClass)
153152
removeTransitionClass(el, startClass)
154-
if (!cb.cancelled && !userWantsControl) {
155-
if (isValidDuration(explicitEnterDuration)) {
156-
setTimeout(cb, explicitEnterDuration)
157-
} else {
158-
whenTransitionEnds(el, type, cb)
153+
if (!cb.cancelled) {
154+
addTransitionClass(el, toClass)
155+
if (!userWantsControl) {
156+
if (isValidDuration(explicitEnterDuration)) {
157+
setTimeout(cb, explicitEnterDuration)
158+
} else {
159+
whenTransitionEnds(el, type, cb)
160+
}
159161
}
160162
}
161163
})
@@ -257,13 +259,15 @@ export function leave (vnode: VNodeWithData, rm: Function) {
257259
addTransitionClass(el, leaveClass)
258260
addTransitionClass(el, leaveActiveClass)
259261
nextFrame(() => {
260-
addTransitionClass(el, leaveToClass)
261262
removeTransitionClass(el, leaveClass)
262-
if (!cb.cancelled && !userWantsControl) {
263-
if (isValidDuration(explicitLeaveDuration)) {
264-
setTimeout(cb, explicitLeaveDuration)
265-
} else {
266-
whenTransitionEnds(el, type, cb)
263+
if (!cb.cancelled) {
264+
addTransitionClass(el, leaveToClass)
265+
if (!userWantsControl) {
266+
if (isValidDuration(explicitLeaveDuration)) {
267+
setTimeout(cb, explicitLeaveDuration)
268+
} else {
269+
whenTransitionEnds(el, type, cb)
270+
}
267271
}
268272
}
269273
})

0 commit comments

Comments
 (0)