Skip to content

Commit

Permalink
[build] 2.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Nov 18, 2016
1 parent 6a18729 commit 3c436b3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
33 changes: 25 additions & 8 deletions dist/vue-router.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* vue-router v2.0.2
* vue-router v2.0.3
* (c) 2016 Evan You
* @license MIT
*/
Expand Down Expand Up @@ -1035,6 +1035,8 @@ function normalizePath (path, parent) {

var regexpCache = Object.create(null)

var regexpParamsCache = Object.create(null)

var regexpCompileCache = Object.create(null)

function createMatcher (routes) {
Expand All @@ -1052,14 +1054,15 @@ function createMatcher (routes) {

if (name) {
var record = nameMap[name]
var paramNames = getParams(record.path)

if (typeof location.params !== 'object') {
location.params = {}
}

if (currentRoute && typeof currentRoute.params === 'object') {
for (var key in currentRoute.params) {
if (!(key in location.params)) {
if (!(key in location.params) && paramNames.indexOf(key) > -1) {
location.params[key] = currentRoute.params[key]
}
}
Expand Down Expand Up @@ -1174,13 +1177,10 @@ function createMatcher (routes) {
return match
}

function matchRoute (
path,
params,
pathname
) {
var keys, regexp
function getRouteRegex (path) {
var hit = regexpCache[path]
var keys, regexp

if (hit) {
keys = hit.keys
regexp = hit.regexp
Expand All @@ -1189,6 +1189,18 @@ function matchRoute (
regexp = index(path, keys)
regexpCache[path] = { keys: keys, regexp: regexp }
}

return { keys: keys, regexp: regexp }
}

function matchRoute (
path,
params,
pathname
) {
var ref = getRouteRegex(path);
var regexp = ref.regexp;
var keys = ref.keys;
var m = pathname.match(regexp)

if (!m) {
Expand Down Expand Up @@ -1222,6 +1234,11 @@ function fillParams (
}
}

function getParams (path) {
return regexpParamsCache[path] ||
(regexpParamsCache[path] = getRouteRegex(path).keys.map(function (key) { return key.name; }))
}

function resolveRecordPath (path, record) {
return resolvePath(path, record.parent ? record.parent.path : '/', true)
}
Expand Down
Loading

0 comments on commit 3c436b3

Please sign in to comment.