Skip to content

Commit

Permalink
build: bundle 3.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Jan 25, 2021
1 parent cbb552c commit cc2288c
Show file tree
Hide file tree
Showing 6 changed files with 358 additions and 69 deletions.
102 changes: 87 additions & 15 deletions dist/vue-router.common.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* vue-router v3.4.9
* (c) 2020 Evan You
* vue-router v3.5.0
* (c) 2021 Evan You
* @license MIT
*/
'use strict';
Expand Down Expand Up @@ -212,23 +212,23 @@ function getFullPath (
return (path || '/') + stringify(query) + hash
}

function isSameRoute (a, b) {
function isSameRoute (a, b, onlyPath) {
if (b === START) {
return a === b
} else if (!b) {
return false
} else if (a.path && b.path) {
return (
a.path.replace(trailingSlashRE, '') === b.path.replace(trailingSlashRE, '') &&
return a.path.replace(trailingSlashRE, '') === b.path.replace(trailingSlashRE, '') && (onlyPath ||
a.hash === b.hash &&
isObjectEqual(a.query, b.query)
)
isObjectEqual(a.query, b.query))
} else if (a.name && b.name) {
return (
a.name === b.name &&
a.hash === b.hash &&
(onlyPath || (
a.hash === b.hash &&
isObjectEqual(a.query, b.query) &&
isObjectEqual(a.params, b.params)
isObjectEqual(a.params, b.params))
)
)
} else {
return false
Expand Down Expand Up @@ -1060,6 +1060,10 @@ var eventTypes = [String, Array];

var noop = function () {};

var warnedCustomSlot;
var warnedTagProp;
var warnedEventProp;

var Link = {
name: 'RouterLink',
props: {
Expand All @@ -1071,7 +1075,9 @@ var Link = {
type: String,
default: 'a'
},
custom: Boolean,
exact: Boolean,
exactPath: Boolean,
append: Boolean,
replace: Boolean,
activeClass: String,
Expand Down Expand Up @@ -1120,8 +1126,8 @@ var Link = {
? createRoute(null, normalizeLocation(route.redirectedFrom), null, router)
: route;

classes[exactActiveClass] = isSameRoute(current, compareTarget);
classes[activeClass] = this.exact
classes[exactActiveClass] = isSameRoute(current, compareTarget, this.exactPath);
classes[activeClass] = this.exact || this.exactPath
? classes[exactActiveClass]
: isIncludedRoute(current, compareTarget);

Expand Down Expand Up @@ -1160,19 +1166,40 @@ var Link = {
});

if (scopedSlot) {
if (process.env.NODE_ENV !== 'production' && !this.custom) {
!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');
warnedCustomSlot = true;
}
if (scopedSlot.length === 1) {
return scopedSlot[0]
} else if (scopedSlot.length > 1 || !scopedSlot.length) {
if (process.env.NODE_ENV !== 'production') {
warn(
false,
("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.")
("<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.")
);
}
return scopedSlot.length === 0 ? h() : h('span', {}, scopedSlot)
}
}

if (process.env.NODE_ENV !== 'production') {
if (this.tag && !warnedTagProp) {
warn(
false,
"<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."
);
warnedTagProp = true;
}
if (this.event && !warnedEventProp) {
warn(
false,
"<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."
);
warnedEventProp = true;
}
}

if (this.tag === 'a') {
data.on = on;
data.attrs = { href: href, 'aria-current': ariaCurrentValue };
Expand Down Expand Up @@ -1308,7 +1335,8 @@ function createRouteMap (
routes,
oldPathList,
oldPathMap,
oldNameMap
oldNameMap,
parentRoute
) {
// the path list is used to control path matching priority
var pathList = oldPathList || [];
Expand All @@ -1318,7 +1346,7 @@ function createRouteMap (
var nameMap = oldNameMap || Object.create(null);

routes.forEach(function (route) {
addRouteRecord(pathList, pathMap, nameMap, route);
addRouteRecord(pathList, pathMap, nameMap, route, parentRoute);
});

// ensure wildcard routes are always at the end
Expand Down Expand Up @@ -1389,6 +1417,11 @@ function addRouteRecord (
path: normalizedPath,
regex: compileRouteRegex(normalizedPath, pathToRegexpOptions),
components: route.components || { default: route.component },
alias: route.alias
? typeof route.alias === 'string'
? [route.alias]
: route.alias
: [],
instances: {},
enteredCbs: {},
name: name,
Expand Down Expand Up @@ -1525,6 +1558,28 @@ function createMatcher (
createRouteMap(routes, pathList, pathMap, nameMap);
}

function addRoute (parentOrRoute, route) {
var parent = (typeof parentOrRoute !== 'object') ? nameMap[parentOrRoute] : undefined;
// $flow-disable-line
createRouteMap([route || parentOrRoute], pathList, pathMap, nameMap, parent);

// add aliases of parent
if (parent) {
createRouteMap(
// $flow-disable-line route is defined if parent is
parent.alias.map(function (alias) { return ({ path: alias, children: [route] }); }),
pathList,
pathMap,
nameMap,
parent
);
}
}

function getRoutes () {
return pathList.map(function (path) { return pathMap[path]; })
}

function match (
raw,
currentRoute,
Expand Down Expand Up @@ -1671,6 +1726,8 @@ function createMatcher (

return {
match: match,
addRoute: addRoute,
getRoutes: getRoutes,
addRoutes: addRoutes
}
}
Expand Down Expand Up @@ -3034,7 +3091,21 @@ VueRouter.prototype.resolve = function resolve (
}
};

VueRouter.prototype.getRoutes = function getRoutes () {
return this.matcher.getRoutes()
};

VueRouter.prototype.addRoute = function addRoute (parentOrRoute, route) {
this.matcher.addRoute(parentOrRoute, route);
if (this.history.current !== START) {
this.history.transitionTo(this.history.getCurrentLocation());
}
};

VueRouter.prototype.addRoutes = function addRoutes (routes) {
if (process.env.NODE_ENV !== 'production') {
warn(false, 'router.addRoutes() is deprecated and has been removed in Vue Router 4. Use router.addRoute() instead.');
}
this.matcher.addRoutes(routes);
if (this.history.current !== START) {
this.history.transitionTo(this.history.getCurrentLocation());
Expand All @@ -3057,9 +3128,10 @@ function createHref (base, fullPath, mode) {
}

VueRouter.install = install;
VueRouter.version = '3.4.9';
VueRouter.version = '3.5.0';
VueRouter.isNavigationFailure = isNavigationFailure;
VueRouter.NavigationFailureType = NavigationFailureType;
VueRouter.START_LOCATION = START;

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

0 comments on commit cc2288c

Please sign in to comment.