Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8d5ddb0

Browse files
committedAug 5, 2020
build: bundle 3.4.0
1 parent ea03de1 commit 8d5ddb0

File tree

6 files changed

+555
-441
lines changed

6 files changed

+555
-441
lines changed
 

‎dist/vue-router.common.js

Lines changed: 136 additions & 108 deletions
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);

‎dist/vue-router.esm.browser.js

Lines changed: 143 additions & 113 deletions
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
*/
@@ -17,14 +17,6 @@ function warn (condition, message) {
1717
}
1818
}
1919

20-
function isError (err) {
21-
return Object.prototype.toString.call(err).indexOf('Error') > -1
22-
}
23-
24-
function isRouterError (err, errorType) {
25-
return isError(err) && err._isRouter && (errorType == null || err.type === errorType)
26-
}
27-
2820
function extend (a, b) {
2921
for (const key in b) {
3022
a[key] = b[key];
@@ -128,7 +120,7 @@ var View = {
128120
};
129121

130122
const configProps = matched.props && matched.props[name];
131-
// save route and configProps in cachce
123+
// save route and configProps in cache
132124
if (configProps) {
133125
extend(cache[name], {
134126
route,
@@ -208,7 +200,8 @@ function resolveQuery (
208200
parsedQuery = {};
209201
}
210202
for (const key in extraQuery) {
211-
parsedQuery[key] = extraQuery[key];
203+
const value = extraQuery[key];
204+
parsedQuery[key] = Array.isArray(value) ? value.map(v => '' + v) : '' + value;
212205
}
213206
return parsedQuery
214207
}
@@ -1882,6 +1875,92 @@ function runQueue (queue, fn, cb) {
18821875
step(0);
18831876
}
18841877

1878+
const NavigationFailureType = {
1879+
redirected: 2,
1880+
aborted: 4,
1881+
cancelled: 8,
1882+
duplicated: 16
1883+
};
1884+
1885+
function createNavigationRedirectedError (from, to) {
1886+
return createRouterError(
1887+
from,
1888+
to,
1889+
NavigationFailureType.redirected,
1890+
`Redirected when going from "${from.fullPath}" to "${stringifyRoute(
1891+
to
1892+
)}" via a navigation guard.`
1893+
)
1894+
}
1895+
1896+
function createNavigationDuplicatedError (from, to) {
1897+
const error = createRouterError(
1898+
from,
1899+
to,
1900+
NavigationFailureType.duplicated,
1901+
`Avoided redundant navigation to current location: "${from.fullPath}".`
1902+
);
1903+
// backwards compatible with the first introduction of Errors
1904+
error.name = 'NavigationDuplicated';
1905+
return error
1906+
}
1907+
1908+
function createNavigationCancelledError (from, to) {
1909+
return createRouterError(
1910+
from,
1911+
to,
1912+
NavigationFailureType.cancelled,
1913+
`Navigation cancelled from "${from.fullPath}" to "${
1914+
to.fullPath
1915+
}" with a new navigation.`
1916+
)
1917+
}
1918+
1919+
function createNavigationAbortedError (from, to) {
1920+
return createRouterError(
1921+
from,
1922+
to,
1923+
NavigationFailureType.aborted,
1924+
`Navigation aborted from "${from.fullPath}" to "${
1925+
to.fullPath
1926+
}" via a navigation guard.`
1927+
)
1928+
}
1929+
1930+
function createRouterError (from, to, type, message) {
1931+
const error = new Error(message);
1932+
error._isRouter = true;
1933+
error.from = from;
1934+
error.to = to;
1935+
error.type = type;
1936+
1937+
return error
1938+
}
1939+
1940+
const propertiesToLog = ['params', 'query', 'hash'];
1941+
1942+
function stringifyRoute (to) {
1943+
if (typeof to === 'string') return to
1944+
if ('path' in to) return to.path
1945+
const location = {};
1946+
propertiesToLog.forEach(key => {
1947+
if (key in to) location[key] = to[key];
1948+
});
1949+
return JSON.stringify(location, null, 2)
1950+
}
1951+
1952+
function isError (err) {
1953+
return Object.prototype.toString.call(err).indexOf('Error') > -1
1954+
}
1955+
1956+
function isNavigationFailure (err, errorType) {
1957+
return (
1958+
isError(err) &&
1959+
err._isRouter &&
1960+
(errorType == null || err.type === errorType)
1961+
)
1962+
}
1963+
18851964
/* */
18861965

18871966
function resolveAsyncComponents (matched) {
@@ -1988,77 +2067,6 @@ function once (fn) {
19882067
}
19892068
}
19902069

1991-
const NavigationFailureType = {
1992-
redirected: 1,
1993-
aborted: 2,
1994-
cancelled: 3,
1995-
duplicated: 4
1996-
};
1997-
1998-
function createNavigationRedirectedError (from, to) {
1999-
return createRouterError(
2000-
from,
2001-
to,
2002-
NavigationFailureType.redirected,
2003-
`Redirected when going from "${from.fullPath}" to "${stringifyRoute(
2004-
to
2005-
)}" via a navigation guard.`
2006-
)
2007-
}
2008-
2009-
function createNavigationDuplicatedError (from, to) {
2010-
return createRouterError(
2011-
from,
2012-
to,
2013-
NavigationFailureType.duplicated,
2014-
`Avoided redundant navigation to current location: "${from.fullPath}".`
2015-
)
2016-
}
2017-
2018-
function createNavigationCancelledError (from, to) {
2019-
return createRouterError(
2020-
from,
2021-
to,
2022-
NavigationFailureType.cancelled,
2023-
`Navigation cancelled from "${from.fullPath}" to "${
2024-
to.fullPath
2025-
}" with a new navigation.`
2026-
)
2027-
}
2028-
2029-
function createNavigationAbortedError (from, to) {
2030-
return createRouterError(
2031-
from,
2032-
to,
2033-
NavigationFailureType.aborted,
2034-
`Navigation aborted from "${from.fullPath}" to "${
2035-
to.fullPath
2036-
}" via a navigation guard.`
2037-
)
2038-
}
2039-
2040-
function createRouterError (from, to, type, message) {
2041-
const error = new Error(message);
2042-
error._isRouter = true;
2043-
error.from = from;
2044-
error.to = to;
2045-
error.type = type;
2046-
2047-
return error
2048-
}
2049-
2050-
const propertiesToLog = ['params', 'query', 'hash'];
2051-
2052-
function stringifyRoute (to) {
2053-
if (typeof to === 'string') return to
2054-
if ('path' in to) return to.path
2055-
const location = {};
2056-
propertiesToLog.forEach(key => {
2057-
if (key in to) location[key] = to[key];
2058-
});
2059-
return JSON.stringify(location, null, 2)
2060-
}
2061-
20622070
/* */
20632071

20642072
class History {
@@ -2119,7 +2127,17 @@ class History {
21192127
onComplete,
21202128
onAbort
21212129
) {
2122-
const route = this.router.match(location, this.current);
2130+
let route;
2131+
// catch redirect option https://github.com/vuejs/vue-router/issues/3201
2132+
try {
2133+
route = this.router.match(location, this.current);
2134+
} catch (e) {
2135+
this.errorCbs.forEach(cb => {
2136+
cb(e);
2137+
});
2138+
// Exception should still be thrown
2139+
throw e
2140+
}
21232141
this.confirmTransition(
21242142
route,
21252143
() => {
@@ -2147,7 +2165,7 @@ class History {
21472165
this.ready = true;
21482166
// Initial redirection should still trigger the onReady onSuccess
21492167
// https://github.com/vuejs/vue-router/issues/3225
2150-
if (!isRouterError(err, NavigationFailureType.redirected)) {
2168+
if (!isNavigationFailure(err, NavigationFailureType.redirected)) {
21512169
this.readyErrorCbs.forEach(cb => {
21522170
cb(err);
21532171
});
@@ -2167,7 +2185,7 @@ class History {
21672185
// changed after adding errors with
21682186
// https://github.com/vuejs/vue-router/pull/3047 before that change,
21692187
// redirect and aborted navigation would produce an err == null
2170-
if (!isRouterError(err) && isError(err)) {
2188+
if (!isNavigationFailure(err) && isError(err)) {
21712189
if (this.errorCbs.length) {
21722190
this.errorCbs.forEach(cb => {
21732191
cb(err);
@@ -2718,7 +2736,7 @@ class AbstractHistory extends History {
27182736
this.updateRoute(route);
27192737
},
27202738
err => {
2721-
if (isRouterError(err, NavigationFailureType.duplicated)) {
2739+
if (isNavigationFailure(err, NavigationFailureType.duplicated)) {
27222740
this.index = targetIndex;
27232741
}
27242742
}
@@ -2737,11 +2755,11 @@ class AbstractHistory extends History {
27372755

27382756
/* */
27392757

2740-
2741-
27422758
class VueRouter {
27432759

27442760

2761+
2762+
27452763

27462764

27472765

@@ -2766,7 +2784,8 @@ class VueRouter {
27662784
this.matcher = createMatcher(options.routes || [], this);
27672785

27682786
let mode = options.mode || 'hash';
2769-
this.fallback = mode === 'history' && !supportsPushState && options.fallback !== false;
2787+
this.fallback =
2788+
mode === 'history' && !supportsPushState && options.fallback !== false;
27702789
if (this.fallback) {
27712790
mode = 'hash';
27722791
}
@@ -2792,11 +2811,7 @@ class VueRouter {
27922811
}
27932812
}
27942813

2795-
match (
2796-
raw,
2797-
current,
2798-
redirectedFrom
2799-
) {
2814+
match (raw, current, redirectedFrom) {
28002815
return this.matcher.match(raw, current, redirectedFrom)
28012816
}
28022817

@@ -2805,11 +2820,12 @@ class VueRouter {
28052820
}
28062821

28072822
init (app /* Vue component instance */) {
2808-
assert(
2809-
install.installed,
2810-
`not installed. Make sure to call \`Vue.use(VueRouter)\` ` +
2811-
`before creating root instance.`
2812-
);
2823+
2824+
assert(
2825+
install.installed,
2826+
`not installed. Make sure to call \`Vue.use(VueRouter)\` ` +
2827+
`before creating root instance.`
2828+
);
28132829

28142830
this.apps.push(app);
28152831

@@ -2841,14 +2857,28 @@ class VueRouter {
28412857
const history = this.history;
28422858

28432859
if (history instanceof HTML5History || history instanceof HashHistory) {
2844-
const setupListeners = () => {
2860+
const handleInitialScroll = routeOrError => {
2861+
const from = history.current;
2862+
const expectScroll = this.options.scrollBehavior;
2863+
const supportsScroll = supportsPushState && expectScroll;
2864+
2865+
if (supportsScroll && 'fullPath' in routeOrError) {
2866+
handleScroll(this, routeOrError, from, false);
2867+
}
2868+
};
2869+
const setupListeners = routeOrError => {
28452870
history.setupListeners();
2871+
handleInitialScroll(routeOrError);
28462872
};
2847-
history.transitionTo(history.getCurrentLocation(), setupListeners, setupListeners);
2873+
history.transitionTo(
2874+
history.getCurrentLocation(),
2875+
setupListeners,
2876+
setupListeners
2877+
);
28482878
}
28492879

28502880
history.listen(route => {
2851-
this.apps.forEach((app) => {
2881+
this.apps.forEach(app => {
28522882
app._route = route;
28532883
});
28542884
});
@@ -2917,11 +2947,14 @@ class VueRouter {
29172947
if (!route) {
29182948
return []
29192949
}
2920-
return [].concat.apply([], route.matched.map(m => {
2921-
return Object.keys(m.components).map(key => {
2922-
return m.components[key]
2950+
return [].concat.apply(
2951+
[],
2952+
route.matched.map(m => {
2953+
return Object.keys(m.components).map(key => {
2954+
return m.components[key]
2955+
})
29232956
})
2924-
}))
2957+
)
29252958
}
29262959

29272960
resolve (
@@ -2930,12 +2963,7 @@ class VueRouter {
29302963
append
29312964
) {
29322965
current = current || this.history.current;
2933-
const location = normalizeLocation(
2934-
to,
2935-
current,
2936-
append,
2937-
this
2938-
);
2966+
const location = normalizeLocation(to, current, append, this);
29392967
const route = this.match(location, current);
29402968
const fullPath = route.redirectedFrom || route.fullPath;
29412969
const base = this.history.base;
@@ -2972,7 +3000,9 @@ function createHref (base, fullPath, mode) {
29723000
}
29733001

29743002
VueRouter.install = install;
2975-
VueRouter.version = '3.3.4';
3003+
VueRouter.version = '3.4.0';
3004+
VueRouter.isNavigationFailure = isNavigationFailure;
3005+
VueRouter.NavigationFailureType = NavigationFailureType;
29763006

29773007
if (inBrowser && window.Vue) {
29783008
window.Vue.use(VueRouter);

‎dist/vue-router.esm.browser.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/vue-router.esm.js

Lines changed: 136 additions & 108 deletions
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
*/
@@ -17,14 +17,6 @@ function warn (condition, message) {
1717
}
1818
}
1919

20-
function isError (err) {
21-
return Object.prototype.toString.call(err).indexOf('Error') > -1
22-
}
23-
24-
function isRouterError (err, errorType) {
25-
return isError(err) && err._isRouter && (errorType == null || err.type === errorType)
26-
}
27-
2820
function extend (a, b) {
2921
for (var key in b) {
3022
a[key] = b[key];
@@ -133,7 +125,7 @@ var View = {
133125
};
134126

135127
var configProps = matched.props && matched.props[name];
136-
// save route and configProps in cachce
128+
// save route and configProps in cache
137129
if (configProps) {
138130
extend(cache[name], {
139131
route: route,
@@ -215,7 +207,8 @@ function resolveQuery (
215207
parsedQuery = {};
216208
}
217209
for (var key in extraQuery) {
218-
parsedQuery[key] = extraQuery[key];
210+
var value = extraQuery[key];
211+
parsedQuery[key] = Array.isArray(value) ? value.map(function (v) { return '' + v; }) : '' + value;
219212
}
220213
return parsedQuery
221214
}
@@ -1904,6 +1897,88 @@ function runQueue (queue, fn, cb) {
19041897
step(0);
19051898
}
19061899

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

19091984
function resolveAsyncComponents (matched) {
@@ -2013,73 +2088,6 @@ function once (fn) {
20132088
}
20142089
}
20152090

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

20852093
var History = function History (router, base) {
@@ -2121,7 +2129,17 @@ History.prototype.transitionTo = function transitionTo (
21212129
) {
21222130
var this$1 = this;
21232131

2124-
var route = this.router.match(location, this.current);
2132+
var route;
2133+
// catch redirect option https://github.com/vuejs/vue-router/issues/3201
2134+
try {
2135+
route = this.router.match(location, this.current);
2136+
} catch (e) {
2137+
this.errorCbs.forEach(function (cb) {
2138+
cb(e);
2139+
});
2140+
// Exception should still be thrown
2141+
throw e
2142+
}
21252143
this.confirmTransition(
21262144
route,
21272145
function () {
@@ -2149,7 +2167,7 @@ History.prototype.transitionTo = function transitionTo (
21492167
this$1.ready = true;
21502168
// Initial redirection should still trigger the onReady onSuccess
21512169
// https://github.com/vuejs/vue-router/issues/3225
2152-
if (!isRouterError(err, NavigationFailureType.redirected)) {
2170+
if (!isNavigationFailure(err, NavigationFailureType.redirected)) {
21532171
this$1.readyErrorCbs.forEach(function (cb) {
21542172
cb(err);
21552173
});
@@ -2171,7 +2189,7 @@ History.prototype.confirmTransition = function confirmTransition (route, onCompl
21712189
// changed after adding errors with
21722190
// https://github.com/vuejs/vue-router/pull/3047 before that change,
21732191
// redirect and aborted navigation would produce an err == null
2174-
if (!isRouterError(err) && isError(err)) {
2192+
if (!isNavigationFailure(err) && isError(err)) {
21752193
if (this$1.errorCbs.length) {
21762194
this$1.errorCbs.forEach(function (cb) {
21772195
cb(err);
@@ -2757,7 +2775,7 @@ var AbstractHistory = /*@__PURE__*/(function (History) {
27572775
this$1.updateRoute(route);
27582776
},
27592777
function (err) {
2760-
if (isRouterError(err, NavigationFailureType.duplicated)) {
2778+
if (isNavigationFailure(err, NavigationFailureType.duplicated)) {
27612779
this$1.index = targetIndex;
27622780
}
27632781
}
@@ -2778,8 +2796,6 @@ var AbstractHistory = /*@__PURE__*/(function (History) {
27782796

27792797
/* */
27802798

2781-
2782-
27832799
var VueRouter = function VueRouter (options) {
27842800
if ( options === void 0 ) options = {};
27852801

@@ -2792,7 +2808,8 @@ var VueRouter = function VueRouter (options) {
27922808
this.matcher = createMatcher(options.routes || [], this);
27932809

27942810
var mode = options.mode || 'hash';
2795-
this.fallback = mode === 'history' && !supportsPushState && options.fallback !== false;
2811+
this.fallback =
2812+
mode === 'history' && !supportsPushState && options.fallback !== false;
27962813
if (this.fallback) {
27972814
mode = 'hash';
27982815
}
@@ -2820,11 +2837,7 @@ var VueRouter = function VueRouter (options) {
28202837

28212838
var prototypeAccessors = { currentRoute: { configurable: true } };
28222839

2823-
VueRouter.prototype.match = function match (
2824-
raw,
2825-
current,
2826-
redirectedFrom
2827-
) {
2840+
VueRouter.prototype.match = function match (raw, current, redirectedFrom) {
28282841
return this.matcher.match(raw, current, redirectedFrom)
28292842
};
28302843

@@ -2835,11 +2848,12 @@ prototypeAccessors.currentRoute.get = function () {
28352848
VueRouter.prototype.init = function init (app /* Vue component instance */) {
28362849
var this$1 = this;
28372850

2838-
process.env.NODE_ENV !== 'production' && assert(
2839-
install.installed,
2840-
"not installed. Make sure to call `Vue.use(VueRouter)` " +
2841-
"before creating root instance."
2842-
);
2851+
process.env.NODE_ENV !== 'production' &&
2852+
assert(
2853+
install.installed,
2854+
"not installed. Make sure to call `Vue.use(VueRouter)` " +
2855+
"before creating root instance."
2856+
);
28432857

28442858
this.apps.push(app);
28452859

@@ -2871,10 +2885,24 @@ VueRouter.prototype.init = function init (app /* Vue component instance */) {
28712885
var history = this.history;
28722886

28732887
if (history instanceof HTML5History || history instanceof HashHistory) {
2874-
var setupListeners = function () {
2888+
var handleInitialScroll = function (routeOrError) {
2889+
var from = history.current;
2890+
var expectScroll = this$1.options.scrollBehavior;
2891+
var supportsScroll = supportsPushState && expectScroll;
2892+
2893+
if (supportsScroll && 'fullPath' in routeOrError) {
2894+
handleScroll(this$1, routeOrError, from, false);
2895+
}
2896+
};
2897+
var setupListeners = function (routeOrError) {
28752898
history.setupListeners();
2899+
handleInitialScroll(routeOrError);
28762900
};
2877-
history.transitionTo(history.getCurrentLocation(), setupListeners, setupListeners);
2901+
history.transitionTo(
2902+
history.getCurrentLocation(),
2903+
setupListeners,
2904+
setupListeners
2905+
);
28782906
}
28792907

28802908
history.listen(function (route) {
@@ -2951,11 +2979,14 @@ VueRouter.prototype.getMatchedComponents = function getMatchedComponents (to) {
29512979
if (!route) {
29522980
return []
29532981
}
2954-
return [].concat.apply([], route.matched.map(function (m) {
2955-
return Object.keys(m.components).map(function (key) {
2956-
return m.components[key]
2982+
return [].concat.apply(
2983+
[],
2984+
route.matched.map(function (m) {
2985+
return Object.keys(m.components).map(function (key) {
2986+
return m.components[key]
2987+
})
29572988
})
2958-
}))
2989+
)
29592990
};
29602991

29612992
VueRouter.prototype.resolve = function resolve (
@@ -2964,12 +2995,7 @@ VueRouter.prototype.resolve = function resolve (
29642995
append
29652996
) {
29662997
current = current || this.history.current;
2967-
var location = normalizeLocation(
2968-
to,
2969-
current,
2970-
append,
2971-
this
2972-
);
2998+
var location = normalizeLocation(to, current, append, this);
29732999
var route = this.match(location, current);
29743000
var fullPath = route.redirectedFrom || route.fullPath;
29753001
var base = this.history.base;
@@ -3007,7 +3033,9 @@ function createHref (base, fullPath, mode) {
30073033
}
30083034

30093035
VueRouter.install = install;
3010-
VueRouter.version = '3.3.4';
3036+
VueRouter.version = '3.4.0';
3037+
VueRouter.isNavigationFailure = isNavigationFailure;
3038+
VueRouter.NavigationFailureType = NavigationFailureType;
30113039

30123040
if (inBrowser && window.Vue) {
30133041
window.Vue.use(VueRouter);

‎dist/vue-router.js

Lines changed: 136 additions & 108 deletions
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
*/
@@ -23,14 +23,6 @@
2323
}
2424
}
2525

26-
function isError (err) {
27-
return Object.prototype.toString.call(err).indexOf('Error') > -1
28-
}
29-
30-
function isRouterError (err, errorType) {
31-
return isError(err) && err._isRouter && (errorType == null || err.type === errorType)
32-
}
33-
3426
function extend (a, b) {
3527
for (var key in b) {
3628
a[key] = b[key];
@@ -139,7 +131,7 @@
139131
};
140132

141133
var configProps = matched.props && matched.props[name];
142-
// save route and configProps in cachce
134+
// save route and configProps in cache
143135
if (configProps) {
144136
extend(cache[name], {
145137
route: route,
@@ -221,7 +213,8 @@
221213
parsedQuery = {};
222214
}
223215
for (var key in extraQuery) {
224-
parsedQuery[key] = extraQuery[key];
216+
var value = extraQuery[key];
217+
parsedQuery[key] = Array.isArray(value) ? value.map(function (v) { return '' + v; }) : '' + value;
225218
}
226219
return parsedQuery
227220
}
@@ -1910,6 +1903,88 @@
19101903
step(0);
19111904
}
19121905

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

19151990
function resolveAsyncComponents (matched) {
@@ -2019,73 +2094,6 @@
20192094
}
20202095
}
20212096

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

20912099
var History = function History (router, base) {
@@ -2127,7 +2135,17 @@
21272135
) {
21282136
var this$1 = this;
21292137

2130-
var route = this.router.match(location, this.current);
2138+
var route;
2139+
// catch redirect option https://github.com/vuejs/vue-router/issues/3201
2140+
try {
2141+
route = this.router.match(location, this.current);
2142+
} catch (e) {
2143+
this.errorCbs.forEach(function (cb) {
2144+
cb(e);
2145+
});
2146+
// Exception should still be thrown
2147+
throw e
2148+
}
21312149
this.confirmTransition(
21322150
route,
21332151
function () {
@@ -2155,7 +2173,7 @@
21552173
this$1.ready = true;
21562174
// Initial redirection should still trigger the onReady onSuccess
21572175
// https://github.com/vuejs/vue-router/issues/3225
2158-
if (!isRouterError(err, NavigationFailureType.redirected)) {
2176+
if (!isNavigationFailure(err, NavigationFailureType.redirected)) {
21592177
this$1.readyErrorCbs.forEach(function (cb) {
21602178
cb(err);
21612179
});
@@ -2177,7 +2195,7 @@
21772195
// changed after adding errors with
21782196
// https://github.com/vuejs/vue-router/pull/3047 before that change,
21792197
// redirect and aborted navigation would produce an err == null
2180-
if (!isRouterError(err) && isError(err)) {
2198+
if (!isNavigationFailure(err) && isError(err)) {
21812199
if (this$1.errorCbs.length) {
21822200
this$1.errorCbs.forEach(function (cb) {
21832201
cb(err);
@@ -2763,7 +2781,7 @@
27632781
this$1.updateRoute(route);
27642782
},
27652783
function (err) {
2766-
if (isRouterError(err, NavigationFailureType.duplicated)) {
2784+
if (isNavigationFailure(err, NavigationFailureType.duplicated)) {
27672785
this$1.index = targetIndex;
27682786
}
27692787
}
@@ -2784,8 +2802,6 @@
27842802

27852803
/* */
27862804

2787-
2788-
27892805
var VueRouter = function VueRouter (options) {
27902806
if ( options === void 0 ) options = {};
27912807

@@ -2798,7 +2814,8 @@
27982814
this.matcher = createMatcher(options.routes || [], this);
27992815

28002816
var mode = options.mode || 'hash';
2801-
this.fallback = mode === 'history' && !supportsPushState && options.fallback !== false;
2817+
this.fallback =
2818+
mode === 'history' && !supportsPushState && options.fallback !== false;
28022819
if (this.fallback) {
28032820
mode = 'hash';
28042821
}
@@ -2826,11 +2843,7 @@
28262843

28272844
var prototypeAccessors = { currentRoute: { configurable: true } };
28282845

2829-
VueRouter.prototype.match = function match (
2830-
raw,
2831-
current,
2832-
redirectedFrom
2833-
) {
2846+
VueRouter.prototype.match = function match (raw, current, redirectedFrom) {
28342847
return this.matcher.match(raw, current, redirectedFrom)
28352848
};
28362849

@@ -2841,11 +2854,12 @@
28412854
VueRouter.prototype.init = function init (app /* Vue component instance */) {
28422855
var this$1 = this;
28432856

2844-
assert(
2845-
install.installed,
2846-
"not installed. Make sure to call `Vue.use(VueRouter)` " +
2847-
"before creating root instance."
2848-
);
2857+
2858+
assert(
2859+
install.installed,
2860+
"not installed. Make sure to call `Vue.use(VueRouter)` " +
2861+
"before creating root instance."
2862+
);
28492863

28502864
this.apps.push(app);
28512865

@@ -2877,10 +2891,24 @@
28772891
var history = this.history;
28782892

28792893
if (history instanceof HTML5History || history instanceof HashHistory) {
2880-
var setupListeners = function () {
2894+
var handleInitialScroll = function (routeOrError) {
2895+
var from = history.current;
2896+
var expectScroll = this$1.options.scrollBehavior;
2897+
var supportsScroll = supportsPushState && expectScroll;
2898+
2899+
if (supportsScroll && 'fullPath' in routeOrError) {
2900+
handleScroll(this$1, routeOrError, from, false);
2901+
}
2902+
};
2903+
var setupListeners = function (routeOrError) {
28812904
history.setupListeners();
2905+
handleInitialScroll(routeOrError);
28822906
};
2883-
history.transitionTo(history.getCurrentLocation(), setupListeners, setupListeners);
2907+
history.transitionTo(
2908+
history.getCurrentLocation(),
2909+
setupListeners,
2910+
setupListeners
2911+
);
28842912
}
28852913

28862914
history.listen(function (route) {
@@ -2957,11 +2985,14 @@
29572985
if (!route) {
29582986
return []
29592987
}
2960-
return [].concat.apply([], route.matched.map(function (m) {
2961-
return Object.keys(m.components).map(function (key) {
2962-
return m.components[key]
2988+
return [].concat.apply(
2989+
[],
2990+
route.matched.map(function (m) {
2991+
return Object.keys(m.components).map(function (key) {
2992+
return m.components[key]
2993+
})
29632994
})
2964-
}))
2995+
)
29652996
};
29662997

29672998
VueRouter.prototype.resolve = function resolve (
@@ -2970,12 +3001,7 @@
29703001
append
29713002
) {
29723003
current = current || this.history.current;
2973-
var location = normalizeLocation(
2974-
to,
2975-
current,
2976-
append,
2977-
this
2978-
);
3004+
var location = normalizeLocation(to, current, append, this);
29793005
var route = this.match(location, current);
29803006
var fullPath = route.redirectedFrom || route.fullPath;
29813007
var base = this.history.base;
@@ -3013,7 +3039,9 @@
30133039
}
30143040

30153041
VueRouter.install = install;
3016-
VueRouter.version = '3.3.4';
3042+
VueRouter.version = '3.4.0';
3043+
VueRouter.isNavigationFailure = isNavigationFailure;
3044+
VueRouter.NavigationFailureType = NavigationFailureType;
30173045

30183046
if (inBrowser && window.Vue) {
30193047
window.Vue.use(VueRouter);

‎dist/vue-router.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.