Skip to content

Commit 3cad567

Browse files
committed
refactor(utils): merge extend and assign util function
1 parent c621a3b commit 3cad567

File tree

4 files changed

+12
-18
lines changed

4 files changed

+12
-18
lines changed

Diff for: src/components/link.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* @flow */
22

33
import { createRoute, isSameRoute, isIncludedRoute } from '../util/route'
4-
import { _Vue } from '../install'
4+
import { extend } from '../util/misc'
55

66
// work around weird flow bug
77
const toTypes: Array<Function> = [String, Object]
@@ -88,7 +88,6 @@ export default {
8888
if (a) {
8989
// in case the <a> is a static node
9090
a.isStatic = false
91-
const extend = _Vue.util.extend
9291
const aData = a.data = extend({}, a.data)
9392
aData.on = on
9493
const aAttrs = a.data.attrs = extend({}, a.data.attrs)

Diff for: src/components/view.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { warn } from '../util/warn'
2+
import { extend } from '../util/misc'
23

34
export default {
45
name: 'RouterView',
@@ -10,6 +11,7 @@ export default {
1011
}
1112
},
1213
render (_, { props, children, parent, data }) {
14+
// used by devtools to display a router-view badge
1315
data.routerView = true
1416

1517
// directly use parent context's createElement() function
@@ -106,10 +108,3 @@ function resolveProps (route, config) {
106108
}
107109
}
108110
}
109-
110-
function extend (to, from) {
111-
for (const key in from) {
112-
to[key] = from[key]
113-
}
114-
return to
115-
}

Diff for: src/util/location.js

+3-9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { parsePath, resolvePath } from './path'
55
import { resolveQuery } from './query'
66
import { fillParams } from './params'
77
import { warn } from './warn'
8+
import { extend } from './misc'
89

910
export function normalizeLocation (
1011
raw: RawLocation,
@@ -20,9 +21,9 @@ export function normalizeLocation (
2021

2122
// relative params
2223
if (!next.path && next.params && current) {
23-
next = assign({}, next)
24+
next = extend({}, next)
2425
next._normalized = true
25-
const params: any = assign(assign({}, current.params), next.params)
26+
const params: any = extend(extend({}, current.params), next.params)
2627
if (current.name) {
2728
next.name = current.name
2829
next.params = params
@@ -59,10 +60,3 @@ export function normalizeLocation (
5960
hash
6061
}
6162
}
62-
63-
function assign (a, b) {
64-
for (const key in b) {
65-
a[key] = b[key]
66-
}
67-
return a
68-
}

Diff for: src/util/misc.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export function extend (a, b) {
2+
for (const key in b) {
3+
a[key] = b[key]
4+
}
5+
return a
6+
}

0 commit comments

Comments
 (0)