Skip to content

Commit

Permalink
[build] 2.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jun 29, 2017
1 parent 9326d44 commit 5dd0e8c
Show file tree
Hide file tree
Showing 4 changed files with 326 additions and 311 deletions.
211 changes: 108 additions & 103 deletions dist/vue-router.common.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* vue-router v2.6.0
* vue-router v2.7.0
* (c) 2017 Evan You
* @license MIT
*/
Expand All @@ -19,6 +19,10 @@ function warn (condition, message) {
}
}

function isError (err) {
return Object.prototype.toString.call(err).indexOf('Error') > -1
}

var View = {
name: 'router-view',
functional: true,
Expand Down Expand Up @@ -520,7 +524,7 @@ function install (Vue) {

var strats = Vue.config.optionMergeStrategies;
// use the same hook merging strategy for route hooks
strats.beforeRouteEnter = strats.beforeRouteLeave = strats.created;
strats.beforeRouteEnter = strats.beforeRouteLeave = strats.beforeRouteUpdate = strats.created;
}

/* */
Expand Down Expand Up @@ -1660,6 +1664,107 @@ function runQueue (queue, fn, cb) {

/* */

function resolveAsyncComponents (matched) {
return function (to, from, next) {
var hasAsync = false;
var pending = 0;
var error = null;

flatMapComponents(matched, function (def, _, match, key) {
// if it's a function and doesn't have cid attached,
// assume it's an async component resolve function.
// we are not using Vue's default async resolving mechanism because
// we want to halt the navigation until the incoming component has been
// resolved.
if (typeof def === 'function' && def.cid === undefined) {
hasAsync = true;
pending++;

var resolve = once(function (resolvedDef) {
if (resolvedDef.__esModule && resolvedDef.default) {
resolvedDef = resolvedDef.default;
}
// save resolved on async factory in case it's used elsewhere
def.resolved = typeof resolvedDef === 'function'
? resolvedDef
: _Vue.extend(resolvedDef);
match.components[key] = resolvedDef;
pending--;
if (pending <= 0) {
next();
}
});

var reject = once(function (reason) {
var msg = "Failed to resolve async component " + key + ": " + reason;
process.env.NODE_ENV !== 'production' && warn(false, msg);
if (!error) {
error = isError(reason)
? reason
: new Error(msg);
next(error);
}
});

var res;
try {
res = def(resolve, reject);
} catch (e) {
reject(e);
}
if (res) {
if (typeof res.then === 'function') {
res.then(resolve, reject);
} else {
// new syntax in Vue 2.3
var comp = res.component;
if (comp && typeof comp.then === 'function') {
comp.then(resolve, reject);
}
}
}
}
});

if (!hasAsync) { next(); }
}
}

function flatMapComponents (
matched,
fn
) {
return flatten(matched.map(function (m) {
return Object.keys(m.components).map(function (key) { return fn(
m.components[key],
m.instances[key],
m, key
); })
}))
}

function flatten (arr) {
return Array.prototype.concat.apply([], arr)
}

// in Webpack 2, require.ensure now also returns a Promise
// so the resolve/reject functions may get called an extra time
// if the user uses an arrow function shorthand that happens to
// return that Promise.
function once (fn) {
var called = false;
return function () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];

if (called) { return }
called = true;
return fn.apply(this, args)
}
}

/* */

var History = function History (router, base) {
this.router = router;
this.base = normalizeBase(base);
Expand Down Expand Up @@ -1955,106 +2060,6 @@ function poll (
}
}

function resolveAsyncComponents (matched) {
return function (to, from, next) {
var hasAsync = false;
var pending = 0;
var error = null;

flatMapComponents(matched, function (def, _, match, key) {
// if it's a function and doesn't have cid attached,
// assume it's an async component resolve function.
// we are not using Vue's default async resolving mechanism because
// we want to halt the navigation until the incoming component has been
// resolved.
if (typeof def === 'function' && def.cid === undefined) {
hasAsync = true;
pending++;

var resolve = once(function (resolvedDef) {
// save resolved on async factory in case it's used elsewhere
def.resolved = typeof resolvedDef === 'function'
? resolvedDef
: _Vue.extend(resolvedDef);
match.components[key] = resolvedDef;
pending--;
if (pending <= 0) {
next();
}
});

var reject = once(function (reason) {
var msg = "Failed to resolve async component " + key + ": " + reason;
process.env.NODE_ENV !== 'production' && warn(false, msg);
if (!error) {
error = isError(reason)
? reason
: new Error(msg);
next(error);
}
});

var res;
try {
res = def(resolve, reject);
} catch (e) {
reject(e);
}
if (res) {
if (typeof res.then === 'function') {
res.then(resolve, reject);
} else {
// new syntax in Vue 2.3
var comp = res.component;
if (comp && typeof comp.then === 'function') {
comp.then(resolve, reject);
}
}
}
}
});

if (!hasAsync) { next(); }
}
}

function flatMapComponents (
matched,
fn
) {
return flatten(matched.map(function (m) {
return Object.keys(m.components).map(function (key) { return fn(
m.components[key],
m.instances[key],
m, key
); })
}))
}

function flatten (arr) {
return Array.prototype.concat.apply([], arr)
}

// in Webpack 2, require.ensure now also returns a Promise
// so the resolve/reject functions may get called an extra time
// if the user uses an arrow function shorthand that happens to
// return that Promise.
function once (fn) {
var called = false;
return function () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];

if (called) { return }
called = true;
return fn.apply(this, args)
}
}

function isError (err) {
return Object.prototype.toString.call(err).indexOf('Error') > -1
}

/* */


Expand Down Expand Up @@ -2493,7 +2498,7 @@ function createHref (base, fullPath, mode) {
}

VueRouter.install = install;
VueRouter.version = '2.6.0';
VueRouter.version = '2.7.0';

if (inBrowser && window.Vue) {
window.Vue.use(VueRouter);
Expand Down
Loading

0 comments on commit 5dd0e8c

Please sign in to comment.