import { PathParser } from './matcher/pathParserRanker'
import { Router } from './router'
import { RouteLocationNormalized } from './types'
+import { assign, omit } from './utils'
function formatRouteLocation(
routeLocation: RouteLocationNormalized,
tooltip?: string
) {
- const copy = {
- ...routeLocation,
+ const copy = assign({}, routeLocation, {
// remove variables that can contain vue instances
- matched: routeLocation.matched.map(
- ({ instances, children, aliasOf, ...rest }) => rest
+ matched: routeLocation.matched.map(matched =>
+ omit(matched, ['instances', 'children', 'aliasOf'])
),
- }
+ })
return {
_custom: {
}
export let noop = () => {}
+
+export const omit = <T extends Record<string, any>>(
+ object: T,
+ paths: Array<keyof T>
+) => {
+ const result: Record<string, any> = {}
+ for (let key in object) {
+ if (
+ paths.indexOf(key) >= 0 ||
+ !Object.prototype.hasOwnProperty.call(object, key)
+ ) {
+ continue
+ }
+ result[key] = object[key]
+ }
+ return result
+}