Skip to content

Commit 3b9fb2d

Browse files
committed
detect synchronous done callback in transitions (fix vuejs#1244)
1 parent 3333598 commit 3b9fb2d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/transition/transition.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ function Transition (el, id, hooks, vm) {
3737
this.op =
3838
this.cb = null
3939
this.justEntered = false
40+
this.entered = this.left = false
4041
this.typeCache = {}
4142
// bind
4243
var self = this
@@ -79,7 +80,11 @@ p.enter = function (op, cb) {
7980
this.cb = cb
8081
addClass(this.el, this.enterClass)
8182
op()
83+
this.entered = false
8284
this.callHookWithCb('enter')
85+
if (this.entered) {
86+
return // user called done synchronously.
87+
}
8388
this.cancel = this.hooks && this.hooks.enterCancelled
8489
queue.push(this.enterNextTick)
8590
}
@@ -117,6 +122,7 @@ p.enterNextTick = function () {
117122
*/
118123

119124
p.enterDone = function () {
125+
this.entered = true
120126
this.cancel = this.pendingJsCb = null
121127
removeClass(this.el, this.enterClass)
122128
this.callHook('afterEnter')
@@ -150,7 +156,11 @@ p.leave = function (op, cb) {
150156
this.op = op
151157
this.cb = cb
152158
addClass(this.el, this.leaveClass)
159+
this.left = false
153160
this.callHookWithCb('leave')
161+
if (this.left) {
162+
return // user called done synchronously.
163+
}
154164
this.cancel = this.hooks && this.hooks.leaveCancelled
155165
// only need to handle leaveDone if
156166
// 1. the transition is already done (synchronously called
@@ -189,6 +199,7 @@ p.leaveNextTick = function () {
189199
*/
190200

191201
p.leaveDone = function () {
202+
this.left = true
192203
this.cancel = this.pendingJsCb = null
193204
this.op()
194205
removeClass(this.el, this.leaveClass)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy