Skip to content

Commit 0a96b95

Browse files
committed
support arbitrary route keys
1 parent 1f7411e commit 0a96b95

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

index.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,7 @@ exports.sync = function (store, router) {
2929
}
3030
var to = transition.to
3131
currentPath = to.path
32-
store.dispatch('router/ROUTE_CHANGED', {
33-
path: to.path,
34-
query: to.query,
35-
name: to.name,
36-
params: to.params
37-
})
32+
store.dispatch('router/ROUTE_CHANGED', to)
3833
})
3934
}
4035

@@ -44,7 +39,6 @@ function patchStore (store) {
4439
store._dispatching = true
4540
set(store.state, 'route', {
4641
path: '',
47-
name: '',
4842
query: null,
4943
params: null
5044
})
@@ -55,10 +49,16 @@ function patchStore (store) {
5549
route: {
5650
mutations: {
5751
'router/ROUTE_CHANGED': function (state, to) {
58-
state.path = to.path
59-
state.name = to.name
60-
state.query = to.query
61-
state.params = to.params
52+
Object.keys(to).forEach(key => {
53+
if (key !== 'matched') {
54+
set(state, key, to[key])
55+
}
56+
})
57+
Object.keys(state).forEach(key => {
58+
if (!(key in to)) {
59+
state[key] = null
60+
}
61+
})
6262
}
6363
}
6464
}

0 commit comments

Comments
 (0)