Skip to content

Commit cc2288c

Browse files
committed
build: bundle 3.5.0
1 parent cbb552c commit cc2288c

6 files changed

+358
-69
lines changed

dist/vue-router.common.js

+87-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
2-
* vue-router v3.4.9
3-
* (c) 2020 Evan You
2+
* vue-router v3.5.0
3+
* (c) 2021 Evan You
44
* @license MIT
55
*/
66
'use strict';
@@ -212,23 +212,23 @@ function getFullPath (
212212
return (path || '/') + stringify(query) + hash
213213
}
214214

215-
function isSameRoute (a, b) {
215+
function isSameRoute (a, b, onlyPath) {
216216
if (b === START) {
217217
return a === b
218218
} else if (!b) {
219219
return false
220220
} else if (a.path && b.path) {
221-
return (
222-
a.path.replace(trailingSlashRE, '') === b.path.replace(trailingSlashRE, '') &&
221+
return a.path.replace(trailingSlashRE, '') === b.path.replace(trailingSlashRE, '') && (onlyPath ||
223222
a.hash === b.hash &&
224-
isObjectEqual(a.query, b.query)
225-
)
223+
isObjectEqual(a.query, b.query))
226224
} else if (a.name && b.name) {
227225
return (
228226
a.name === b.name &&
229-
a.hash === b.hash &&
227+
(onlyPath || (
228+
a.hash === b.hash &&
230229
isObjectEqual(a.query, b.query) &&
231-
isObjectEqual(a.params, b.params)
230+
isObjectEqual(a.params, b.params))
231+
)
232232
)
233233
} else {
234234
return false
@@ -1060,6 +1060,10 @@ var eventTypes = [String, Array];
10601060

10611061
var noop = function () {};
10621062

1063+
var warnedCustomSlot;
1064+
var warnedTagProp;
1065+
var warnedEventProp;
1066+
10631067
var Link = {
10641068
name: 'RouterLink',
10651069
props: {
@@ -1071,7 +1075,9 @@ var Link = {
10711075
type: String,
10721076
default: 'a'
10731077
},
1078+
custom: Boolean,
10741079
exact: Boolean,
1080+
exactPath: Boolean,
10751081
append: Boolean,
10761082
replace: Boolean,
10771083
activeClass: String,
@@ -1120,8 +1126,8 @@ var Link = {
11201126
? createRoute(null, normalizeLocation(route.redirectedFrom), null, router)
11211127
: route;
11221128

1123-
classes[exactActiveClass] = isSameRoute(current, compareTarget);
1124-
classes[activeClass] = this.exact
1129+
classes[exactActiveClass] = isSameRoute(current, compareTarget, this.exactPath);
1130+
classes[activeClass] = this.exact || this.exactPath
11251131
? classes[exactActiveClass]
11261132
: isIncludedRoute(current, compareTarget);
11271133

@@ -1160,19 +1166,40 @@ var Link = {
11601166
});
11611167

11621168
if (scopedSlot) {
1169+
if (process.env.NODE_ENV !== 'production' && !this.custom) {
1170+
!warnedCustomSlot && warn(false, 'In Vue Router 4, the v-slot API will by default wrap its content with an <a> element. Use the custom prop to remove this warning:\n<router-link v-slot="{ navigate, href }" custom></router-link>\n');
1171+
warnedCustomSlot = true;
1172+
}
11631173
if (scopedSlot.length === 1) {
11641174
return scopedSlot[0]
11651175
} else if (scopedSlot.length > 1 || !scopedSlot.length) {
11661176
if (process.env.NODE_ENV !== 'production') {
11671177
warn(
11681178
false,
1169-
("RouterLink with to=\"" + (this.to) + "\" is trying to use a scoped slot but it didn't provide exactly one child. Wrapping the content with a span element.")
1179+
("<router-link> with to=\"" + (this.to) + "\" is trying to use a scoped slot but it didn't provide exactly one child. Wrapping the content with a span element.")
11701180
);
11711181
}
11721182
return scopedSlot.length === 0 ? h() : h('span', {}, scopedSlot)
11731183
}
11741184
}
11751185

1186+
if (process.env.NODE_ENV !== 'production') {
1187+
if (this.tag && !warnedTagProp) {
1188+
warn(
1189+
false,
1190+
"<router-link>'s tag prop is deprecated and has been removed in Vue Router 4. Use the v-slot API to remove this warning: https://next.router.vuejs.org/guide/migration/#removal-of-event-and-tag-props-in-router-link."
1191+
);
1192+
warnedTagProp = true;
1193+
}
1194+
if (this.event && !warnedEventProp) {
1195+
warn(
1196+
false,
1197+
"<router-link>'s event prop is deprecated and has been removed in Vue Router 4. Use the v-slot API to remove this warning: https://next.router.vuejs.org/guide/migration/#removal-of-event-and-tag-props-in-router-link."
1198+
);
1199+
warnedEventProp = true;
1200+
}
1201+
}
1202+
11761203
if (this.tag === 'a') {
11771204
data.on = on;
11781205
data.attrs = { href: href, 'aria-current': ariaCurrentValue };
@@ -1308,7 +1335,8 @@ function createRouteMap (
13081335
routes,
13091336
oldPathList,
13101337
oldPathMap,
1311-
oldNameMap
1338+
oldNameMap,
1339+
parentRoute
13121340
) {
13131341
// the path list is used to control path matching priority
13141342
var pathList = oldPathList || [];
@@ -1318,7 +1346,7 @@ function createRouteMap (
13181346
var nameMap = oldNameMap || Object.create(null);
13191347

13201348
routes.forEach(function (route) {
1321-
addRouteRecord(pathList, pathMap, nameMap, route);
1349+
addRouteRecord(pathList, pathMap, nameMap, route, parentRoute);
13221350
});
13231351

13241352
// ensure wildcard routes are always at the end
@@ -1389,6 +1417,11 @@ function addRouteRecord (
13891417
path: normalizedPath,
13901418
regex: compileRouteRegex(normalizedPath, pathToRegexpOptions),
13911419
components: route.components || { default: route.component },
1420+
alias: route.alias
1421+
? typeof route.alias === 'string'
1422+
? [route.alias]
1423+
: route.alias
1424+
: [],
13921425
instances: {},
13931426
enteredCbs: {},
13941427
name: name,
@@ -1525,6 +1558,28 @@ function createMatcher (
15251558
createRouteMap(routes, pathList, pathMap, nameMap);
15261559
}
15271560

1561+
function addRoute (parentOrRoute, route) {
1562+
var parent = (typeof parentOrRoute !== 'object') ? nameMap[parentOrRoute] : undefined;
1563+
// $flow-disable-line
1564+
createRouteMap([route || parentOrRoute], pathList, pathMap, nameMap, parent);
1565+
1566+
// add aliases of parent
1567+
if (parent) {
1568+
createRouteMap(
1569+
// $flow-disable-line route is defined if parent is
1570+
parent.alias.map(function (alias) { return ({ path: alias, children: [route] }); }),
1571+
pathList,
1572+
pathMap,
1573+
nameMap,
1574+
parent
1575+
);
1576+
}
1577+
}
1578+
1579+
function getRoutes () {
1580+
return pathList.map(function (path) { return pathMap[path]; })
1581+
}
1582+
15281583
function match (
15291584
raw,
15301585
currentRoute,
@@ -1671,6 +1726,8 @@ function createMatcher (
16711726

16721727
return {
16731728
match: match,
1729+
addRoute: addRoute,
1730+
getRoutes: getRoutes,
16741731
addRoutes: addRoutes
16751732
}
16761733
}
@@ -3034,7 +3091,21 @@ VueRouter.prototype.resolve = function resolve (
30343091
}
30353092
};
30363093

3094+
VueRouter.prototype.getRoutes = function getRoutes () {
3095+
return this.matcher.getRoutes()
3096+
};
3097+
3098+
VueRouter.prototype.addRoute = function addRoute (parentOrRoute, route) {
3099+
this.matcher.addRoute(parentOrRoute, route);
3100+
if (this.history.current !== START) {
3101+
this.history.transitionTo(this.history.getCurrentLocation());
3102+
}
3103+
};
3104+
30373105
VueRouter.prototype.addRoutes = function addRoutes (routes) {
3106+
if (process.env.NODE_ENV !== 'production') {
3107+
warn(false, 'router.addRoutes() is deprecated and has been removed in Vue Router 4. Use router.addRoute() instead.');
3108+
}
30383109
this.matcher.addRoutes(routes);
30393110
if (this.history.current !== START) {
30403111
this.history.transitionTo(this.history.getCurrentLocation());
@@ -3057,9 +3128,10 @@ function createHref (base, fullPath, mode) {
30573128
}
30583129

30593130
VueRouter.install = install;
3060-
VueRouter.version = '3.4.9';
3131+
VueRouter.version = '3.5.0';
30613132
VueRouter.isNavigationFailure = isNavigationFailure;
30623133
VueRouter.NavigationFailureType = NavigationFailureType;
3134+
VueRouter.START_LOCATION = START;
30633135

30643136
if (inBrowser && window.Vue) {
30653137
window.Vue.use(VueRouter);

0 commit comments

Comments
 (0)