@@ -108,7 +108,7 @@ export function deactivate (view, transition, next) {
108
108
export function activate ( view , transition , depth , cb , reuse ) {
109
109
let handler = transition . activateQueue [ depth ]
110
110
if ( ! handler ) {
111
- // fix 1.0.0-alpha.3 compat
111
+ saveChildView ( view )
112
112
if ( view . _bound ) {
113
113
view . setComponent ( null )
114
114
}
@@ -138,16 +138,12 @@ export function activate (view, transition, depth, cb, reuse) {
138
138
component = view . childVM
139
139
component . $loadingRouteData = loading
140
140
} else {
141
+ saveChildView ( view )
142
+
141
143
// unbuild current component. this step also destroys
142
144
// and removes all nested child views.
143
145
view . unbuild ( true )
144
146
145
- // handle keep-alive.
146
- // cache the child view on the kept-alive child vm.
147
- if ( view . keepAlive && view . childVM && view . childView ) {
148
- view . childVM . _keepAliveRouterView = view . childView
149
- }
150
-
151
147
// build the new component. this will also create the
152
148
// direct child view of the current one. it will register
153
149
// itself as view.childView.
@@ -300,6 +296,26 @@ function loadData (component, transition, hook, cb, cleanup) {
300
296
} )
301
297
}
302
298
303
- function isPlainObject ( obj ) {
304
- return Object . prototype . toString . call ( obj ) === '[object Object]'
299
+ /**
300
+ * Save the child view for a kept-alive view so that
301
+ * we can restore it when it is switched back to.
302
+ *
303
+ * @param {Directive } view
304
+ */
305
+
306
+ function saveChildView ( view ) {
307
+ if ( view . keepAlive && view . childVM && view . childView ) {
308
+ view . childVM . _keepAliveRouterView = view . childView
309
+ }
310
+ view . childView = null
311
+ }
312
+
313
+ /**
314
+ * Check plain object.
315
+ *
316
+ * @param {* } val
317
+ */
318
+
319
+ function isPlainObject ( val ) {
320
+ return Object . prototype . toString . call ( val ) === '[object Object]'
305
321
}
0 commit comments