Skip to content

Commit 8d5ddb0

Browse files
committed
build: bundle 3.4.0
1 parent ea03de1 commit 8d5ddb0

6 files changed

+555
-441
lines changed

Diff for: dist/vue-router.common.js

+136-108
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* vue-router v3.3.4
2+
* vue-router v3.4.0
33
* (c) 2020 Evan You
44
* @license MIT
55
*/
@@ -19,14 +19,6 @@ function warn (condition, message) {
1919
}
2020
}
2121

22-
function isError (err) {
23-
return Object.prototype.toString.call(err).indexOf('Error') > -1
24-
}
25-
26-
function isRouterError (err, errorType) {
27-
return isError(err) && err._isRouter && (errorType == null || err.type === errorType)
28-
}
29-
3022
function extend (a, b) {
3123
for (var key in b) {
3224
a[key] = b[key];
@@ -135,7 +127,7 @@ var View = {
135127
};
136128

137129
var configProps = matched.props && matched.props[name];
138-
// save route and configProps in cachce
130+
// save route and configProps in cache
139131
if (configProps) {
140132
extend(cache[name], {
141133
route: route,
@@ -217,7 +209,8 @@ function resolveQuery (
217209
parsedQuery = {};
218210
}
219211
for (var key in extraQuery) {
220-
parsedQuery[key] = extraQuery[key];
212+
var value = extraQuery[key];
213+
parsedQuery[key] = Array.isArray(value) ? value.map(function (v) { return '' + v; }) : '' + value;
221214
}
222215
return parsedQuery
223216
}
@@ -1906,6 +1899,88 @@ function runQueue (queue, fn, cb) {
19061899
step(0);
19071900
}
19081901

1902+
var NavigationFailureType = {
1903+
redirected: 2,
1904+
aborted: 4,
1905+
cancelled: 8,
1906+
duplicated: 16
1907+
};
1908+
1909+
function createNavigationRedirectedError (from, to) {
1910+
return createRouterError(
1911+
from,
1912+
to,
1913+
NavigationFailureType.redirected,
1914+
("Redirected when going from \"" + (from.fullPath) + "\" to \"" + (stringifyRoute(
1915+
to
1916+
)) + "\" via a navigation guard.")
1917+
)
1918+
}
1919+
1920+
function createNavigationDuplicatedError (from, to) {
1921+
var error = createRouterError(
1922+
from,
1923+
to,
1924+
NavigationFailureType.duplicated,
1925+
("Avoided redundant navigation to current location: \"" + (from.fullPath) + "\".")
1926+
);
1927+
// backwards compatible with the first introduction of Errors
1928+
error.name = 'NavigationDuplicated';
1929+
return error
1930+
}
1931+
1932+
function createNavigationCancelledError (from, to) {
1933+
return createRouterError(
1934+
from,
1935+
to,
1936+
NavigationFailureType.cancelled,
1937+
("Navigation cancelled from \"" + (from.fullPath) + "\" to \"" + (to.fullPath) + "\" with a new navigation.")
1938+
)
1939+
}
1940+
1941+
function createNavigationAbortedError (from, to) {
1942+
return createRouterError(
1943+
from,
1944+
to,
1945+
NavigationFailureType.aborted,
1946+
("Navigation aborted from \"" + (from.fullPath) + "\" to \"" + (to.fullPath) + "\" via a navigation guard.")
1947+
)
1948+
}
1949+
1950+
function createRouterError (from, to, type, message) {
1951+
var error = new Error(message);
1952+
error._isRouter = true;
1953+
error.from = from;
1954+
error.to = to;
1955+
error.type = type;
1956+
1957+
return error
1958+
}
1959+
1960+
var propertiesToLog = ['params', 'query', 'hash'];
1961+
1962+
function stringifyRoute (to) {
1963+
if (typeof to === 'string') { return to }
1964+
if ('path' in to) { return to.path }
1965+
var location = {};
1966+
propertiesToLog.forEach(function (key) {
1967+
if (key in to) { location[key] = to[key]; }
1968+
});
1969+
return JSON.stringify(location, null, 2)
1970+
}
1971+
1972+
function isError (err) {
1973+
return Object.prototype.toString.call(err).indexOf('Error') > -1
1974+
}
1975+
1976+
function isNavigationFailure (err, errorType) {
1977+
return (
1978+
isError(err) &&
1979+
err._isRouter &&
1980+
(errorType == null || err.type === errorType)
1981+
)
1982+
}
1983+
19091984
/* */
19101985

19111986
function resolveAsyncComponents (matched) {
@@ -2015,73 +2090,6 @@ function once (fn) {
20152090
}
20162091
}
20172092

2018-
var NavigationFailureType = {
2019-
redirected: 1,
2020-
aborted: 2,
2021-
cancelled: 3,
2022-
duplicated: 4
2023-
};
2024-
2025-
function createNavigationRedirectedError (from, to) {
2026-
return createRouterError(
2027-
from,
2028-
to,
2029-
NavigationFailureType.redirected,
2030-
("Redirected when going from \"" + (from.fullPath) + "\" to \"" + (stringifyRoute(
2031-
to
2032-
)) + "\" via a navigation guard.")
2033-
)
2034-
}
2035-
2036-
function createNavigationDuplicatedError (from, to) {
2037-
return createRouterError(
2038-
from,
2039-
to,
2040-
NavigationFailureType.duplicated,
2041-
("Avoided redundant navigation to current location: \"" + (from.fullPath) + "\".")
2042-
)
2043-
}
2044-
2045-
function createNavigationCancelledError (from, to) {
2046-
return createRouterError(
2047-
from,
2048-
to,
2049-
NavigationFailureType.cancelled,
2050-
("Navigation cancelled from \"" + (from.fullPath) + "\" to \"" + (to.fullPath) + "\" with a new navigation.")
2051-
)
2052-
}
2053-
2054-
function createNavigationAbortedError (from, to) {
2055-
return createRouterError(
2056-
from,
2057-
to,
2058-
NavigationFailureType.aborted,
2059-
("Navigation aborted from \"" + (from.fullPath) + "\" to \"" + (to.fullPath) + "\" via a navigation guard.")
2060-
)
2061-
}
2062-
2063-
function createRouterError (from, to, type, message) {
2064-
var error = new Error(message);
2065-
error._isRouter = true;
2066-
error.from = from;
2067-
error.to = to;
2068-
error.type = type;
2069-
2070-
return error
2071-
}
2072-
2073-
var propertiesToLog = ['params', 'query', 'hash'];
2074-
2075-
function stringifyRoute (to) {
2076-
if (typeof to === 'string') { return to }
2077-
if ('path' in to) { return to.path }
2078-
var location = {};
2079-
propertiesToLog.forEach(function (key) {
2080-
if (key in to) { location[key] = to[key]; }
2081-
});
2082-
return JSON.stringify(location, null, 2)
2083-
}
2084-
20852093
/* */
20862094

20872095
var History = function History (router, base) {
@@ -2123,7 +2131,17 @@ History.prototype.transitionTo = function transitionTo (
21232131
) {
21242132
var this$1 = this;
21252133

2126-
var route = this.router.match(location, this.current);
2134+
var route;
2135+
// catch redirect option https://github.com/vuejs/vue-router/issues/3201
2136+
try {
2137+
route = this.router.match(location, this.current);
2138+
} catch (e) {
2139+
this.errorCbs.forEach(function (cb) {
2140+
cb(e);
2141+
});
2142+
// Exception should still be thrown
2143+
throw e
2144+
}
21272145
this.confirmTransition(
21282146
route,
21292147
function () {
@@ -2151,7 +2169,7 @@ History.prototype.transitionTo = function transitionTo (
21512169
this$1.ready = true;
21522170
// Initial redirection should still trigger the onReady onSuccess
21532171
// https://github.com/vuejs/vue-router/issues/3225
2154-
if (!isRouterError(err, NavigationFailureType.redirected)) {
2172+
if (!isNavigationFailure(err, NavigationFailureType.redirected)) {
21552173
this$1.readyErrorCbs.forEach(function (cb) {
21562174
cb(err);
21572175
});
@@ -2173,7 +2191,7 @@ History.prototype.confirmTransition = function confirmTransition (route, onCompl
21732191
// changed after adding errors with
21742192
// https://github.com/vuejs/vue-router/pull/3047 before that change,
21752193
// redirect and aborted navigation would produce an err == null
2176-
if (!isRouterError(err) && isError(err)) {
2194+
if (!isNavigationFailure(err) && isError(err)) {
21772195
if (this$1.errorCbs.length) {
21782196
this$1.errorCbs.forEach(function (cb) {
21792197
cb(err);
@@ -2759,7 +2777,7 @@ var AbstractHistory = /*@__PURE__*/(function (History) {
27592777
this$1.updateRoute(route);
27602778
},
27612779
function (err) {
2762-
if (isRouterError(err, NavigationFailureType.duplicated)) {
2780+
if (isNavigationFailure(err, NavigationFailureType.duplicated)) {
27632781
this$1.index = targetIndex;
27642782
}
27652783
}
@@ -2780,8 +2798,6 @@ var AbstractHistory = /*@__PURE__*/(function (History) {
27802798

27812799
/* */
27822800

2783-
2784-
27852801
var VueRouter = function VueRouter (options) {
27862802
if ( options === void 0 ) options = {};
27872803

@@ -2794,7 +2810,8 @@ var VueRouter = function VueRouter (options) {
27942810
this.matcher = createMatcher(options.routes || [], this);
27952811

27962812
var mode = options.mode || 'hash';
2797-
this.fallback = mode === 'history' && !supportsPushState && options.fallback !== false;
2813+
this.fallback =
2814+
mode === 'history' && !supportsPushState && options.fallback !== false;
27982815
if (this.fallback) {
27992816
mode = 'hash';
28002817
}
@@ -2822,11 +2839,7 @@ var VueRouter = function VueRouter (options) {
28222839

28232840
var prototypeAccessors = { currentRoute: { configurable: true } };
28242841

2825-
VueRouter.prototype.match = function match (
2826-
raw,
2827-
current,
2828-
redirectedFrom
2829-
) {
2842+
VueRouter.prototype.match = function match (raw, current, redirectedFrom) {
28302843
return this.matcher.match(raw, current, redirectedFrom)
28312844
};
28322845

@@ -2837,11 +2850,12 @@ prototypeAccessors.currentRoute.get = function () {
28372850
VueRouter.prototype.init = function init (app /* Vue component instance */) {
28382851
var this$1 = this;
28392852

2840-
process.env.NODE_ENV !== 'production' && assert(
2841-
install.installed,
2842-
"not installed. Make sure to call `Vue.use(VueRouter)` " +
2843-
"before creating root instance."
2844-
);
2853+
process.env.NODE_ENV !== 'production' &&
2854+
assert(
2855+
install.installed,
2856+
"not installed. Make sure to call `Vue.use(VueRouter)` " +
2857+
"before creating root instance."
2858+
);
28452859

28462860
this.apps.push(app);
28472861

@@ -2873,10 +2887,24 @@ VueRouter.prototype.init = function init (app /* Vue component instance */) {
28732887
var history = this.history;
28742888

28752889
if (history instanceof HTML5History || history instanceof HashHistory) {
2876-
var setupListeners = function () {
2890+
var handleInitialScroll = function (routeOrError) {
2891+
var from = history.current;
2892+
var expectScroll = this$1.options.scrollBehavior;
2893+
var supportsScroll = supportsPushState && expectScroll;
2894+
2895+
if (supportsScroll && 'fullPath' in routeOrError) {
2896+
handleScroll(this$1, routeOrError, from, false);
2897+
}
2898+
};
2899+
var setupListeners = function (routeOrError) {
28772900
history.setupListeners();
2901+
handleInitialScroll(routeOrError);
28782902
};
2879-
history.transitionTo(history.getCurrentLocation(), setupListeners, setupListeners);
2903+
history.transitionTo(
2904+
history.getCurrentLocation(),
2905+
setupListeners,
2906+
setupListeners
2907+
);
28802908
}
28812909

28822910
history.listen(function (route) {
@@ -2953,11 +2981,14 @@ VueRouter.prototype.getMatchedComponents = function getMatchedComponents (to) {
29532981
if (!route) {
29542982
return []
29552983
}
2956-
return [].concat.apply([], route.matched.map(function (m) {
2957-
return Object.keys(m.components).map(function (key) {
2958-
return m.components[key]
2984+
return [].concat.apply(
2985+
[],
2986+
route.matched.map(function (m) {
2987+
return Object.keys(m.components).map(function (key) {
2988+
return m.components[key]
2989+
})
29592990
})
2960-
}))
2991+
)
29612992
};
29622993

29632994
VueRouter.prototype.resolve = function resolve (
@@ -2966,12 +2997,7 @@ VueRouter.prototype.resolve = function resolve (
29662997
append
29672998
) {
29682999
current = current || this.history.current;
2969-
var location = normalizeLocation(
2970-
to,
2971-
current,
2972-
append,
2973-
this
2974-
);
3000+
var location = normalizeLocation(to, current, append, this);
29753001
var route = this.match(location, current);
29763002
var fullPath = route.redirectedFrom || route.fullPath;
29773003
var base = this.history.base;
@@ -3009,7 +3035,9 @@ function createHref (base, fullPath, mode) {
30093035
}
30103036

30113037
VueRouter.install = install;
3012-
VueRouter.version = '3.3.4';
3038+
VueRouter.version = '3.4.0';
3039+
VueRouter.isNavigationFailure = isNavigationFailure;
3040+
VueRouter.NavigationFailureType = NavigationFailureType;
30133041

30143042
if (inBrowser && window.Vue) {
30153043
window.Vue.use(VueRouter);

0 commit comments

Comments
 (0)