Skip to content

Commit 8f93a5c

Browse files
authored
fix(devtools): use assign instead of spread operator (vuejs#672)
2 parents 1064206 + 558851c commit 8f93a5c

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/devtools.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ import { RouteRecordMatcher } from './matcher/pathMatcher'
1515
import { PathParser } from './matcher/pathParserRanker'
1616
import { Router } from './router'
1717
import { RouteLocationNormalized } from './types'
18+
import { assign } from './utils'
1819

1920
function formatRouteLocation(
2021
routeLocation: RouteLocationNormalized,
2122
tooltip?: string
2223
) {
23-
const copy = {
24-
...routeLocation,
24+
const copy = assign({}, routeLocation, {
2525
// 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'])
2828
),
29-
}
29+
})
3030

3131
return {
3232
_custom: {
@@ -472,3 +472,17 @@ function isRouteMatching(route: RouteRecordMatcher, filter: string): boolean {
472472

473473
return route.children.some(child => isRouteMatching(child, filter))
474474
}
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

Comments
 (0)