Skip to content

Commit 95558dc

Browse files
committed
wip
1 parent b490b94 commit 95558dc

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

src/directives/view.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,25 @@ export default function (Vue) {
3939
let router = this.router = route.router
4040
router._views.unshift(this)
4141

42-
// note the views are in reverse order.
43-
let parentView = router._views[1]
42+
// locate the parent view
43+
let parentView
44+
let parent = this.vm
45+
while (parent) {
46+
if (parent._routerView) {
47+
parentView = parent._routerView
48+
break
49+
}
50+
parent = parent.$parent
51+
}
4452
if (parentView) {
4553
// register self as a child of the parent view,
4654
// instead of activating now. This is so that the
4755
// child's activate hook is called after the
4856
// parent's has resolved.
4957
this.parentView = parentView
5058
parentView.childView = this
59+
} else {
60+
router._rootView = this
5161
}
5262

5363
// handle late-rendered view

src/pipeline.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,12 @@ export function activate (view, transition, depth, cb, reuse) {
159159
component = view.build({
160160
_meta: {
161161
$loadingRouteData: loading
162+
},
163+
created () {
164+
this._routerView = view
162165
}
163166
})
167+
164168
// handle keep-alive.
165169
// when a kept-alive child vm is restored, we need to
166170
// add its cached child views into the router's view list,

src/transition.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ export default class RouteTransition {
2929
// the deactivate queue is an array of router-view
3030
// directive instances that need to be deactivated,
3131
// deepest first.
32-
this.deactivateQueue = router._views
32+
let view = router._rootView
33+
this.deactivateQueue = router._views = []
34+
while (view) {
35+
this.deactivateQueue.unshift(view)
36+
view = view.childView
37+
}
3338

3439
// check the default handler of the deepest match
3540
let matched = to.matched

0 commit comments

Comments
 (0)