Skip to content

Commit 9431c59

Browse files
committed
fix $route being observed + expose $route.matched
1 parent 859162c commit 9431c59

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ class Router {
267267
*/
268268

269269
_addRoute (path, handler, segments) {
270+
handler.path = path
270271
guardComponent(path, handler)
271272
segments.push({
272273
path: path,

src/route.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ export default class Route {
3535
this.path = path
3636
this.router = router
3737
// for internal use
38-
this._matched = matched || router._notFoundHandler
38+
this.matched = matched || router._notFoundHandler
39+
// Important: freeze self to prevent observation
40+
Object.freeze(this)
3941
}
4042
}

src/transition.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ export default class RouteTransition {
3232
this.deactivateQueue = router._views
3333

3434
// check the default handler of the deepest match
35-
let matched = to._matched
36-
? Array.prototype.slice.call(to._matched)
35+
let matched = to.matched
36+
? Array.prototype.slice.call(to.matched)
3737
: []
3838

3939
// the activate queue is an array of route handlers

0 commit comments

Comments
 (0)