Skip to content

Commit 862744c

Browse files
committed
test css+js mixed transition mode
1 parent 033efa7 commit 862744c

File tree

3 files changed

+140
-58
lines changed

3 files changed

+140
-58
lines changed

src/transition/transition.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ p.enter = function (op, cb) {
5959
addClass(this.el, this.enterClass)
6060
op()
6161
this.callHookWithCb('enter')
62+
queue.push(this.enterNextTick)
6263
}
6364

6465
/**
@@ -76,7 +77,7 @@ p.enterNextTick = function () {
7677
this.setupCssCb(transitionEndEvent, enterDone)
7778
} else if (type === TYPE_ANIMATION) {
7879
this.setupCssCb(animationEndEvent, enterDone)
79-
} else {
80+
} else if (!this.pendingJsCb) {
8081
enterDone()
8182
}
8283
}
@@ -88,7 +89,7 @@ p.enterNextTick = function () {
8889
p.enterDone = function () {
8990
this.jsCancel = this.pendingJsCb = null
9091
removeClass(this.el, this.enterClass)
91-
this.callHook('enterDone')
92+
this.callHook('afterEnter')
9293
if (this.cb) this.cb()
9394
}
9495

@@ -106,6 +107,11 @@ p.leave = function (op, cb) {
106107
this.cb = cb
107108
addClass(this.el, this.leaveClass)
108109
this.callHookWithCb('leave')
110+
// only need to do leaveNextTick if there's no explicit
111+
// js callback
112+
if (!this.pendingJsCb) {
113+
queue.push(this.leaveNextTick)
114+
}
109115
}
110116

111117
/**
@@ -131,7 +137,7 @@ p.leaveNextTick = function () {
131137
p.leaveDone = function () {
132138
this.op()
133139
removeClass(this.el, this.leaveClass)
134-
this.callHook('leaveDone')
140+
this.callHook('afterLeave')
135141
if (this.cb) this.cb()
136142
}
137143

@@ -194,10 +200,6 @@ p.callHookWithCb = function (type) {
194200
}
195201
this.jsCancel = hook.call(this.vm, this.el, this.pendingJsCb)
196202
}
197-
// only need to handle nextTick stuff if no js cb is provided
198-
if (!this.pendingJsCb) {
199-
queue.push(this[type + 'NextTick'])
200-
}
201203
}
202204

203205
/**

test/unit/specs/directives/component_spec.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ if (_.inBrowser) {
295295
},
296296
leave: function (el, done) {
297297
spy2()
298-
done()
298+
_.nextTick(done)
299299
}
300300
}
301301
}
@@ -307,9 +307,13 @@ if (_.inBrowser) {
307307
expect(spy2).not.toHaveBeenCalled()
308308
expect(el.textContent).toBe('AAABBB')
309309
next()
310-
expect(spy2).toHaveBeenCalled()
311-
expect(el.textContent).toBe('BBB')
312-
done()
310+
_.nextTick(function () {
311+
expect(spy2).toHaveBeenCalled()
312+
_.nextTick(function () {
313+
expect(el.textContent).toBe('BBB')
314+
done()
315+
})
316+
})
313317
})
314318
})
315319

@@ -331,7 +335,7 @@ if (_.inBrowser) {
331335
test: {
332336
enter: function (el, done) {
333337
spy2()
334-
done()
338+
_.nextTick(done)
335339
},
336340
leave: function (el, done) {
337341
spy1()

0 commit comments

Comments
 (0)