Skip to content

Commit 4c3a995

Browse files
committed
detect synchronous done callback in transitions (fix #1244)
1 parent ae8c4c4 commit 4c3a995

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
@@ -35,6 +35,7 @@ function Transition (el, id, hooks, vm) {
3535
this.op =
3636
this.cb = null
3737
this.justEntered = false
38+
this.entered = this.left = false
3839
this.typeCache = {}
3940
// bind
4041
var self = this
@@ -77,7 +78,11 @@ p.enter = function (op, cb) {
7778
this.cb = cb
7879
addClass(this.el, this.enterClass)
7980
op()
81+
this.entered = false
8082
this.callHookWithCb('enter')
83+
if (this.entered) {
84+
return // user called done synchronously.
85+
}
8186
this.cancel = this.hooks && this.hooks.enterCancelled
8287
queue.push(this.enterNextTick)
8388
}
@@ -115,6 +120,7 @@ p.enterNextTick = function () {
115120
*/
116121

117122
p.enterDone = function () {
123+
this.entered = true
118124
this.cancel = this.pendingJsCb = null
119125
removeClass(this.el, this.enterClass)
120126
this.callHook('afterEnter')
@@ -148,7 +154,11 @@ p.leave = function (op, cb) {
148154
this.op = op
149155
this.cb = cb
150156
addClass(this.el, this.leaveClass)
157+
this.left = false
151158
this.callHookWithCb('leave')
159+
if (this.left) {
160+
return // user called done synchronously.
161+
}
152162
this.cancel = this.hooks && this.hooks.leaveCancelled
153163
// only need to handle leaveDone if
154164
// 1. the transition is already done (synchronously called
@@ -187,6 +197,7 @@ p.leaveNextTick = function () {
187197
*/
188198

189199
p.leaveDone = function () {
200+
this.left = true
190201
this.cancel = this.pendingJsCb = null
191202
this.op()
192203
removeClass(this.el, this.leaveClass)

0 commit comments

Comments
 (0)