Skip to content

Commit 34b9abc

Browse files
committed
do not normalize to if already a route in getMatchedComponents() (fix #1381)
1 parent 90ba1cc commit 34b9abc

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,11 @@ export default class VueRouter {
158158
this.go(1)
159159
}
160160

161-
getMatchedComponents (to?: RawLocation): Array<any> {
162-
const route = to
163-
? this.resolve(to).route
161+
getMatchedComponents (to?: RawLocation | Route): Array<any> {
162+
const route: any = to
163+
? to.matched
164+
? to
165+
: this.resolve(to).route
164166
: this.currentRoute
165167
if (!route) {
166168
return []

types/router.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ declare class VueRouter {
2828
go (n: number): void;
2929
back (): void;
3030
forward (): void;
31-
getMatchedComponents (to?: RawLocation): Component[];
31+
getMatchedComponents (to?: RawLocation | Route): Component[];
3232
onReady (cb: Function, errorCb?: Function): void;
3333
onError (cb: Function): void;
3434
addRoutes (routes: RouteConfig[]): void;

0 commit comments

Comments
 (0)