@@ -50,6 +50,10 @@ module.exports = {
50
50
// check dynamic component params
51
51
this . transMode = this . _checkParam ( 'transition-mode' )
52
52
}
53
+
54
+ this . pendingRemovals = 0
55
+ this . pendingRemovalCb = null
56
+
53
57
} else {
54
58
process . env . NODE_ENV !== 'production' && _ . warn (
55
59
'cannot mount component "' + this . expression + '" ' +
@@ -214,9 +218,20 @@ module.exports = {
214
218
remove : function ( child , cb ) {
215
219
var keepAlive = this . keepAlive
216
220
if ( child ) {
221
+ // we may have a component switch when a previous
222
+ // component is still being transitioned out.
223
+ // we want to trigger only one lastest insertion cb
224
+ // when the existing transition finishes.
225
+ this . pendingRemovals ++
226
+ this . pendingRemovalCb = cb
227
+ var self = this
217
228
child . $remove ( function ( ) {
229
+ self . pendingRemovals --
218
230
if ( ! keepAlive ) child . _cleanup ( )
219
- if ( cb ) cb ( )
231
+ if ( ! self . pendingRemovals && self . pendingRemovalCb ) {
232
+ self . pendingRemovalCb ( )
233
+ self . pendingRemovalCb = null
234
+ }
220
235
} )
221
236
} else if ( cb ) {
222
237
cb ( )
@@ -244,9 +259,7 @@ module.exports = {
244
259
break
245
260
case 'out-in' :
246
261
self . remove ( current , function ( ) {
247
- if ( ! target . _isDestroyed ) {
248
- target . $before ( self . anchor , cb )
249
- }
262
+ target . $before ( self . anchor , cb )
250
263
} )
251
264
break
252
265
default :
0 commit comments