Skip to content

Commit 3c436b3

Browse files
committed
[build] 2.0.3
1 parent 6a18729 commit 3c436b3

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

dist/vue-router.js

+25-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* vue-router v2.0.2
2+
* vue-router v2.0.3
33
* (c) 2016 Evan You
44
* @license MIT
55
*/
@@ -1035,6 +1035,8 @@ function normalizePath (path, parent) {
10351035

10361036
var regexpCache = Object.create(null)
10371037

1038+
var regexpParamsCache = Object.create(null)
1039+
10381040
var regexpCompileCache = Object.create(null)
10391041

10401042
function createMatcher (routes) {
@@ -1052,14 +1054,15 @@ function createMatcher (routes) {
10521054

10531055
if (name) {
10541056
var record = nameMap[name]
1057+
var paramNames = getParams(record.path)
10551058

10561059
if (typeof location.params !== 'object') {
10571060
location.params = {}
10581061
}
10591062

10601063
if (currentRoute && typeof currentRoute.params === 'object') {
10611064
for (var key in currentRoute.params) {
1062-
if (!(key in location.params)) {
1065+
if (!(key in location.params) && paramNames.indexOf(key) > -1) {
10631066
location.params[key] = currentRoute.params[key]
10641067
}
10651068
}
@@ -1174,13 +1177,10 @@ function createMatcher (routes) {
11741177
return match
11751178
}
11761179

1177-
function matchRoute (
1178-
path,
1179-
params,
1180-
pathname
1181-
) {
1182-
var keys, regexp
1180+
function getRouteRegex (path) {
11831181
var hit = regexpCache[path]
1182+
var keys, regexp
1183+
11841184
if (hit) {
11851185
keys = hit.keys
11861186
regexp = hit.regexp
@@ -1189,6 +1189,18 @@ function matchRoute (
11891189
regexp = index(path, keys)
11901190
regexpCache[path] = { keys: keys, regexp: regexp }
11911191
}
1192+
1193+
return { keys: keys, regexp: regexp }
1194+
}
1195+
1196+
function matchRoute (
1197+
path,
1198+
params,
1199+
pathname
1200+
) {
1201+
var ref = getRouteRegex(path);
1202+
var regexp = ref.regexp;
1203+
var keys = ref.keys;
11921204
var m = pathname.match(regexp)
11931205

11941206
if (!m) {
@@ -1222,6 +1234,11 @@ function fillParams (
12221234
}
12231235
}
12241236

1237+
function getParams (path) {
1238+
return regexpParamsCache[path] ||
1239+
(regexpParamsCache[path] = getRouteRegex(path).keys.map(function (key) { return key.name; }))
1240+
}
1241+
12251242
function resolveRecordPath (path, record) {
12261243
return resolvePath(path, record.parent ? record.parent.path : '/', true)
12271244
}

0 commit comments

Comments
 (0)