@@ -50,6 +50,10 @@ module.exports = {
5050 // check dynamic component params
5151 this . transMode = this . _checkParam ( 'transition-mode' )
5252 }
53+
54+ this . pendingRemovals = 0
55+ this . pendingRemovalCb = null
56+
5357 } else {
5458 process . env . NODE_ENV !== 'production' && _ . warn (
5559 'cannot mount component "' + this . expression + '" ' +
@@ -214,9 +218,20 @@ module.exports = {
214218 remove : function ( child , cb ) {
215219 var keepAlive = this . keepAlive
216220 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
217228 child . $remove ( function ( ) {
229+ self . pendingRemovals --
218230 if ( ! keepAlive ) child . _cleanup ( )
219- if ( cb ) cb ( )
231+ if ( ! self . pendingRemovals && self . pendingRemovalCb ) {
232+ self . pendingRemovalCb ( )
233+ self . pendingRemovalCb = null
234+ }
220235 } )
221236 } else if ( cb ) {
222237 cb ( )
@@ -244,9 +259,7 @@ module.exports = {
244259 break
245260 case 'out-in' :
246261 self . remove ( current , function ( ) {
247- if ( ! target . _isDestroyed ) {
248- target . $before ( self . anchor , cb )
249- }
262+ target . $before ( self . anchor , cb )
250263 } )
251264 break
252265 default :
0 commit comments