@@ -15,18 +15,18 @@ import { RouteRecordMatcher } from './matcher/pathMatcher'
15
15
import { PathParser } from './matcher/pathParserRanker'
16
16
import { Router } from './router'
17
17
import { RouteLocationNormalized } from './types'
18
+ import { assign } from './utils'
18
19
19
20
function formatRouteLocation (
20
21
routeLocation : RouteLocationNormalized ,
21
22
tooltip ?: string
22
23
) {
23
- const copy = {
24
- ...routeLocation ,
24
+ const copy = assign ( { } , routeLocation , {
25
25
// remove variables that can contain vue instances
26
- matched : routeLocation . matched . map (
27
- ( { instances, children, aliasOf, ... rest } ) => rest
26
+ matched : routeLocation . matched . map ( matched =>
27
+ omit ( matched , [ ' instances' , ' children' , ' aliasOf' ] )
28
28
) ,
29
- }
29
+ } )
30
30
31
31
return {
32
32
_custom : {
@@ -472,3 +472,17 @@ function isRouteMatching(route: RouteRecordMatcher, filter: string): boolean {
472
472
473
473
return route . children . some ( child => isRouteMatching ( child , filter ) )
474
474
}
475
+
476
+ function omit < T extends object , K extends [ ...( keyof T ) [ ] ] > ( obj : T , keys : K ) {
477
+ const ret = { } as {
478
+ [ K2 in Exclude < keyof T , K [ number ] > ] : T [ K2 ]
479
+ }
480
+
481
+ for ( let key in obj ) {
482
+ if ( ! keys . includes ( key as any ) ) {
483
+ // @ts -ignore
484
+ ret [ key ] = obj [ key ]
485
+ }
486
+ }
487
+ return ret
488
+ }
0 commit comments