From c163bbb5dab9921323e357cc40cd015aa0ad1c67 Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 11 Oct 2017 18:10:59 -0400 Subject: [PATCH] [build] 2.8.0 --- dist/vue-router.common.js | 203 +++++++++++++++++++++++++++++--------- dist/vue-router.esm.js | 203 +++++++++++++++++++++++++++++--------- dist/vue-router.js | 203 +++++++++++++++++++++++++++++--------- dist/vue-router.min.js | 4 +- 4 files changed, 467 insertions(+), 146 deletions(-) diff --git a/dist/vue-router.common.js b/dist/vue-router.common.js index 22b042c79..42cf1366e 100644 --- a/dist/vue-router.common.js +++ b/dist/vue-router.common.js @@ -1,5 +1,5 @@ /** - * vue-router v2.7.0 + * vue-router v2.8.0 * (c) 2017 Evan You * @license MIT */ @@ -89,7 +89,7 @@ var View = { } } - // also regiseter instance in prepatch hook + // also register instance in prepatch hook // in case the same component instance is reused across different routes ;(data.hook || (data.hook = {})).prepatch = function (_, vnode) { matched.instances[name] = vnode.componentInstance; @@ -97,6 +97,14 @@ var View = { // resolve props data.props = resolveProps(route, matched.props && matched.props[name]); + data.attrs = {}; + + for (var key in data.props) { + if (!('props' in component) || !(key in component.props)) { + data.attrs[key] = data.props[key]; + delete data.props[key]; + } + } return h(component, data, children) } @@ -154,8 +162,7 @@ function resolveQuery ( parsedQuery = {}; } for (var key in extraQuery) { - var val = extraQuery[key]; - parsedQuery[key] = Array.isArray(val) ? val.slice() : val; + parsedQuery[key] = extraQuery[key]; } return parsedQuery } @@ -232,12 +239,18 @@ function createRoute ( router ) { var stringifyQuery$$1 = router && router.options.stringifyQuery; + + var query = location.query || {}; + try { + query = clone(query); + } catch (e) {} + var route = { name: location.name || (record && record.name), meta: (record && record.meta) || {}, path: location.path || '/', hash: location.hash || '', - query: location.query || {}, + query: query, params: location.params || {}, fullPath: getFullPath(location, stringifyQuery$$1), matched: record ? formatMatch(record) : [] @@ -248,6 +261,20 @@ function createRoute ( return Object.freeze(route) } +function clone (value) { + if (Array.isArray(value)) { + return value.map(clone) + } else if (value && typeof value === 'object') { + var res = {}; + for (var key in value) { + res[key] = clone(value[key]); + } + return res + } else { + return value + } +} + // the starting route that represents the initial state var START = createRoute(null, { path: '/' @@ -301,6 +328,8 @@ function isObjectEqual (a, b) { if ( a === void 0 ) a = {}; if ( b === void 0 ) b = {}; + // handle null value #1566 + if (!a || !b) { return a === b } var aKeys = Object.keys(a); var bKeys = Object.keys(b); if (aKeys.length !== bKeys.length) { @@ -480,7 +509,7 @@ function findAnchor (children) { var _Vue; function install (Vue) { - if (install.installed) { return } + if (install.installed && _Vue === Vue) { return } install.installed = true; _Vue = Vue; @@ -602,14 +631,14 @@ function cleanPath (path) { return path.replace(/\/\//g, '/') } -var index$1 = Array.isArray || function (arr) { +var isarray = Array.isArray || function (arr) { return Object.prototype.toString.call(arr) == '[object Array]'; }; /** * Expose `pathToRegexp`. */ -var index = pathToRegexp; +var pathToRegexp_1 = pathToRegexp; var parse_1 = parse; var compile_1 = compile; var tokensToFunction_1 = tokensToFunction; @@ -786,7 +815,7 @@ function tokensToFunction (tokens) { } } - if (index$1(value)) { + if (isarray(value)) { if (!token.repeat) { throw new TypeError('Expected "' + token.name + '" to not repeat, but received `' + JSON.stringify(value) + '`') } @@ -937,7 +966,7 @@ function stringToRegexp (path, keys, options) { * @return {!RegExp} */ function tokensToRegExp (tokens, keys, options) { - if (!index$1(keys)) { + if (!isarray(keys)) { options = /** @type {!Object} */ (keys || options); keys = []; } @@ -1013,7 +1042,7 @@ function tokensToRegExp (tokens, keys, options) { * @return {!RegExp} */ function pathToRegexp (path, keys, options) { - if (!index$1(keys)) { + if (!isarray(keys)) { options = /** @type {!Object} */ (keys || options); keys = []; } @@ -1024,20 +1053,21 @@ function pathToRegexp (path, keys, options) { return regexpToRegexp(path, /** @type {!Array} */ (keys)) } - if (index$1(path)) { + if (isarray(path)) { return arrayToRegexp(/** @type {!Array} */ (path), /** @type {!Array} */ (keys), options) } return stringToRegexp(/** @type {string} */ (path), /** @type {!Array} */ (keys), options) } -index.parse = parse_1; -index.compile = compile_1; -index.tokensToFunction = tokensToFunction_1; -index.tokensToRegExp = tokensToRegExp_1; +pathToRegexp_1.parse = parse_1; +pathToRegexp_1.compile = compile_1; +pathToRegexp_1.tokensToFunction = tokensToFunction_1; +pathToRegexp_1.tokensToRegExp = tokensToRegExp_1; /* */ +// $flow-disable-line var regexpCompileCache = Object.create(null); function fillParams ( @@ -1048,7 +1078,7 @@ function fillParams ( try { var filler = regexpCompileCache[path] || - (regexpCompileCache[path] = index.compile(path)); + (regexpCompileCache[path] = pathToRegexp_1.compile(path)); return filler(params || {}, { pretty: true }) } catch (e) { if (process.env.NODE_ENV !== 'production') { @@ -1068,7 +1098,9 @@ function createRouteMap ( ) { // the path list is used to control path matching priority var pathList = oldPathList || []; + // $flow-disable-line var pathMap = oldPathMap || Object.create(null); + // $flow-disable-line var nameMap = oldNameMap || Object.create(null); routes.forEach(function (route) { @@ -1110,8 +1142,12 @@ function addRouteRecord ( ); } - var normalizedPath = normalizePath(path, parent); var pathToRegexpOptions = route.pathToRegexpOptions || {}; + var normalizedPath = normalizePath( + path, + parent, + pathToRegexpOptions.strict + ); if (typeof route.caseSensitive === 'boolean') { pathToRegexpOptions.sensitive = route.caseSensitive; @@ -1199,9 +1235,9 @@ function addRouteRecord ( } function compileRouteRegex (path, pathToRegexpOptions) { - var regex = index(path, [], pathToRegexpOptions); + var regex = pathToRegexp_1(path, [], pathToRegexpOptions); if (process.env.NODE_ENV !== 'production') { - var keys = {}; + var keys = Object.create(null); regex.keys.forEach(function (key) { warn(!keys[key.name], ("Duplicate param keys in route with path: \"" + path + "\"")); keys[key.name] = true; @@ -1210,8 +1246,8 @@ function compileRouteRegex (path, pathToRegexpOptions) { return regex } -function normalizePath (path, parent) { - path = path.replace(/\/$/, ''); +function normalizePath (path, parent, strict) { + if (!strict) { path = path.replace(/\/$/, ''); } if (path[0] === '/') { return path } if (parent == null) { return path } return cleanPath(((parent.path) + "/" + path)) @@ -1483,6 +1519,8 @@ function resolveRecordPath (path, record) { var positionStore = Object.create(null); function setupScroll () { + // Fix for #1585 for Firefox + window.history.replaceState({ key: getStateKey() }, ''); window.addEventListener('popstate', function (e) { saveScrollPosition(); if (e.state && e.state.key) { @@ -1514,25 +1552,21 @@ function handleScroll ( router.app.$nextTick(function () { var position = getScrollPosition(); var shouldScroll = behavior(to, from, isPop ? position : null); + if (!shouldScroll) { return } - var isObject = typeof shouldScroll === 'object'; - if (isObject && typeof shouldScroll.selector === 'string') { - var el = document.querySelector(shouldScroll.selector); - if (el) { - var offset = shouldScroll.offset && typeof shouldScroll.offset === 'object' ? shouldScroll.offset : {}; - offset = normalizeOffset(offset); - position = getElementPosition(el, offset); - } else if (isValidPosition(shouldScroll)) { - position = normalizePosition(shouldScroll); - } - } else if (isObject && isValidPosition(shouldScroll)) { - position = normalizePosition(shouldScroll); - } - if (position) { - window.scrollTo(position.x, position.y); + if (typeof shouldScroll.then === 'function') { + shouldScroll.then(function (shouldScroll) { + scrollToPosition((shouldScroll), position); + }).catch(function (err) { + if (process.env.NODE_ENV !== 'production') { + assert(false, err.toString()); + } + }); + } else { + scrollToPosition(shouldScroll, position); } }); } @@ -1586,6 +1620,26 @@ function isNumber (v) { return typeof v === 'number' } +function scrollToPosition (shouldScroll, position) { + var isObject = typeof shouldScroll === 'object'; + if (isObject && typeof shouldScroll.selector === 'string') { + var el = document.querySelector(shouldScroll.selector); + if (el) { + var offset = shouldScroll.offset && typeof shouldScroll.offset === 'object' ? shouldScroll.offset : {}; + offset = normalizeOffset(offset); + position = getElementPosition(el, offset); + } else if (isValidPosition(shouldScroll)) { + position = normalizePosition(shouldScroll); + } + } else if (isObject && isValidPosition(shouldScroll)) { + position = normalizePosition(shouldScroll); + } + + if (position) { + window.scrollTo(position.x, position.y); + } +} + /* */ var supportsPushState = inBrowser && (function () { @@ -1681,7 +1735,7 @@ function resolveAsyncComponents (matched) { pending++; var resolve = once(function (resolvedDef) { - if (resolvedDef.__esModule && resolvedDef.default) { + if (isESModule(resolvedDef)) { resolvedDef = resolvedDef.default; } // save resolved on async factory in case it's used elsewhere @@ -1747,6 +1801,14 @@ function flatten (arr) { return Array.prototype.concat.apply([], arr) } +var hasSymbol = + typeof Symbol === 'function' && + typeof Symbol.toStringTag === 'symbol'; + +function isESModule (obj) { + return obj.__esModule || (hasSymbol && obj[Symbol.toStringTag] === 'Module') +} + // 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 @@ -2075,9 +2137,18 @@ var HTML5History = (function (History$$1) { setupScroll(); } + var initLocation = getLocation(this.base); window.addEventListener('popstate', function (e) { var current = this$1.current; - this$1.transitionTo(getLocation(this$1.base), function (route) { + + // Avoiding first `popstate` event dispatched in some browsers but first + // history route not updated since async guard at the same time. + var location = getLocation(this$1.base); + if (this$1.current === START && location === initLocation) { + return + } + + this$1.transitionTo(location, function (route) { if (expectScroll) { handleScroll(router, route, current, true); } @@ -2161,26 +2232,50 @@ var HashHistory = (function (History$$1) { HashHistory.prototype.setupListeners = function setupListeners () { var this$1 = this; - window.addEventListener('hashchange', function () { + var router = this.router; + var expectScroll = router.options.scrollBehavior; + var supportsScroll = supportsPushState && expectScroll; + + if (supportsScroll) { + setupScroll(); + } + + window.addEventListener(supportsPushState ? 'popstate' : 'hashchange', function () { + var current = this$1.current; if (!ensureSlash()) { return } this$1.transitionTo(getHash(), function (route) { - replaceHash(route.fullPath); + if (supportsScroll) { + handleScroll(this$1.router, route, current, true); + } + if (!supportsPushState) { + replaceHash(route.fullPath); + } }); }); }; HashHistory.prototype.push = function push (location, onComplete, onAbort) { + var this$1 = this; + + var ref = this; + var fromRoute = ref.current; this.transitionTo(location, function (route) { pushHash(route.fullPath); + handleScroll(this$1.router, route, fromRoute, false); onComplete && onComplete(route); }, onAbort); }; HashHistory.prototype.replace = function replace (location, onComplete, onAbort) { + var this$1 = this; + + var ref = this; + var fromRoute = ref.current; this.transitionTo(location, function (route) { replaceHash(route.fullPath); + handleScroll(this$1.router, route, fromRoute, false); onComplete && onComplete(route); }, onAbort); }; @@ -2230,15 +2325,27 @@ function getHash () { return index === -1 ? '' : href.slice(index + 1) } +function getUrl (path) { + var href = window.location.href; + var i = href.indexOf('#'); + var base = i >= 0 ? href.slice(0, i) : href; + return (base + "#" + path) +} + function pushHash (path) { - window.location.hash = path; + if (supportsPushState) { + pushState(getUrl(path)); + } else { + window.location.hash = path; + } } function replaceHash (path) { - var href = window.location.href; - var i = href.indexOf('#'); - var base = i >= 0 ? href.slice(0, i) : href; - window.location.replace((base + "#" + path)); + if (supportsPushState) { + replaceState(getUrl(path)); + } else { + window.location.replace(getUrl(path)); + } } /* */ @@ -2340,7 +2447,7 @@ var VueRouter = function VueRouter (options) { } }; -var prototypeAccessors = { currentRoute: {} }; +var prototypeAccessors = { currentRoute: { configurable: true } }; VueRouter.prototype.match = function match ( raw, @@ -2498,7 +2605,7 @@ function createHref (base, fullPath, mode) { } VueRouter.install = install; -VueRouter.version = '2.7.0'; +VueRouter.version = '2.8.0'; if (inBrowser && window.Vue) { window.Vue.use(VueRouter); diff --git a/dist/vue-router.esm.js b/dist/vue-router.esm.js index a2dc19c1f..2409a8405 100644 --- a/dist/vue-router.esm.js +++ b/dist/vue-router.esm.js @@ -1,5 +1,5 @@ /** - * vue-router v2.7.0 + * vue-router v2.8.0 * (c) 2017 Evan You * @license MIT */ @@ -87,7 +87,7 @@ var View = { } } - // also regiseter instance in prepatch hook + // also register instance in prepatch hook // in case the same component instance is reused across different routes ;(data.hook || (data.hook = {})).prepatch = function (_, vnode) { matched.instances[name] = vnode.componentInstance; @@ -95,6 +95,14 @@ var View = { // resolve props data.props = resolveProps(route, matched.props && matched.props[name]); + data.attrs = {}; + + for (var key in data.props) { + if (!('props' in component) || !(key in component.props)) { + data.attrs[key] = data.props[key]; + delete data.props[key]; + } + } return h(component, data, children) } @@ -152,8 +160,7 @@ function resolveQuery ( parsedQuery = {}; } for (var key in extraQuery) { - var val = extraQuery[key]; - parsedQuery[key] = Array.isArray(val) ? val.slice() : val; + parsedQuery[key] = extraQuery[key]; } return parsedQuery } @@ -230,12 +237,18 @@ function createRoute ( router ) { var stringifyQuery$$1 = router && router.options.stringifyQuery; + + var query = location.query || {}; + try { + query = clone(query); + } catch (e) {} + var route = { name: location.name || (record && record.name), meta: (record && record.meta) || {}, path: location.path || '/', hash: location.hash || '', - query: location.query || {}, + query: query, params: location.params || {}, fullPath: getFullPath(location, stringifyQuery$$1), matched: record ? formatMatch(record) : [] @@ -246,6 +259,20 @@ function createRoute ( return Object.freeze(route) } +function clone (value) { + if (Array.isArray(value)) { + return value.map(clone) + } else if (value && typeof value === 'object') { + var res = {}; + for (var key in value) { + res[key] = clone(value[key]); + } + return res + } else { + return value + } +} + // the starting route that represents the initial state var START = createRoute(null, { path: '/' @@ -299,6 +326,8 @@ function isObjectEqual (a, b) { if ( a === void 0 ) a = {}; if ( b === void 0 ) b = {}; + // handle null value #1566 + if (!a || !b) { return a === b } var aKeys = Object.keys(a); var bKeys = Object.keys(b); if (aKeys.length !== bKeys.length) { @@ -478,7 +507,7 @@ function findAnchor (children) { var _Vue; function install (Vue) { - if (install.installed) { return } + if (install.installed && _Vue === Vue) { return } install.installed = true; _Vue = Vue; @@ -600,14 +629,14 @@ function cleanPath (path) { return path.replace(/\/\//g, '/') } -var index$1 = Array.isArray || function (arr) { +var isarray = Array.isArray || function (arr) { return Object.prototype.toString.call(arr) == '[object Array]'; }; /** * Expose `pathToRegexp`. */ -var index = pathToRegexp; +var pathToRegexp_1 = pathToRegexp; var parse_1 = parse; var compile_1 = compile; var tokensToFunction_1 = tokensToFunction; @@ -784,7 +813,7 @@ function tokensToFunction (tokens) { } } - if (index$1(value)) { + if (isarray(value)) { if (!token.repeat) { throw new TypeError('Expected "' + token.name + '" to not repeat, but received `' + JSON.stringify(value) + '`') } @@ -935,7 +964,7 @@ function stringToRegexp (path, keys, options) { * @return {!RegExp} */ function tokensToRegExp (tokens, keys, options) { - if (!index$1(keys)) { + if (!isarray(keys)) { options = /** @type {!Object} */ (keys || options); keys = []; } @@ -1011,7 +1040,7 @@ function tokensToRegExp (tokens, keys, options) { * @return {!RegExp} */ function pathToRegexp (path, keys, options) { - if (!index$1(keys)) { + if (!isarray(keys)) { options = /** @type {!Object} */ (keys || options); keys = []; } @@ -1022,20 +1051,21 @@ function pathToRegexp (path, keys, options) { return regexpToRegexp(path, /** @type {!Array} */ (keys)) } - if (index$1(path)) { + if (isarray(path)) { return arrayToRegexp(/** @type {!Array} */ (path), /** @type {!Array} */ (keys), options) } return stringToRegexp(/** @type {string} */ (path), /** @type {!Array} */ (keys), options) } -index.parse = parse_1; -index.compile = compile_1; -index.tokensToFunction = tokensToFunction_1; -index.tokensToRegExp = tokensToRegExp_1; +pathToRegexp_1.parse = parse_1; +pathToRegexp_1.compile = compile_1; +pathToRegexp_1.tokensToFunction = tokensToFunction_1; +pathToRegexp_1.tokensToRegExp = tokensToRegExp_1; /* */ +// $flow-disable-line var regexpCompileCache = Object.create(null); function fillParams ( @@ -1046,7 +1076,7 @@ function fillParams ( try { var filler = regexpCompileCache[path] || - (regexpCompileCache[path] = index.compile(path)); + (regexpCompileCache[path] = pathToRegexp_1.compile(path)); return filler(params || {}, { pretty: true }) } catch (e) { if (process.env.NODE_ENV !== 'production') { @@ -1066,7 +1096,9 @@ function createRouteMap ( ) { // the path list is used to control path matching priority var pathList = oldPathList || []; + // $flow-disable-line var pathMap = oldPathMap || Object.create(null); + // $flow-disable-line var nameMap = oldNameMap || Object.create(null); routes.forEach(function (route) { @@ -1108,8 +1140,12 @@ function addRouteRecord ( ); } - var normalizedPath = normalizePath(path, parent); var pathToRegexpOptions = route.pathToRegexpOptions || {}; + var normalizedPath = normalizePath( + path, + parent, + pathToRegexpOptions.strict + ); if (typeof route.caseSensitive === 'boolean') { pathToRegexpOptions.sensitive = route.caseSensitive; @@ -1197,9 +1233,9 @@ function addRouteRecord ( } function compileRouteRegex (path, pathToRegexpOptions) { - var regex = index(path, [], pathToRegexpOptions); + var regex = pathToRegexp_1(path, [], pathToRegexpOptions); if (process.env.NODE_ENV !== 'production') { - var keys = {}; + var keys = Object.create(null); regex.keys.forEach(function (key) { warn(!keys[key.name], ("Duplicate param keys in route with path: \"" + path + "\"")); keys[key.name] = true; @@ -1208,8 +1244,8 @@ function compileRouteRegex (path, pathToRegexpOptions) { return regex } -function normalizePath (path, parent) { - path = path.replace(/\/$/, ''); +function normalizePath (path, parent, strict) { + if (!strict) { path = path.replace(/\/$/, ''); } if (path[0] === '/') { return path } if (parent == null) { return path } return cleanPath(((parent.path) + "/" + path)) @@ -1481,6 +1517,8 @@ function resolveRecordPath (path, record) { var positionStore = Object.create(null); function setupScroll () { + // Fix for #1585 for Firefox + window.history.replaceState({ key: getStateKey() }, ''); window.addEventListener('popstate', function (e) { saveScrollPosition(); if (e.state && e.state.key) { @@ -1512,25 +1550,21 @@ function handleScroll ( router.app.$nextTick(function () { var position = getScrollPosition(); var shouldScroll = behavior(to, from, isPop ? position : null); + if (!shouldScroll) { return } - var isObject = typeof shouldScroll === 'object'; - if (isObject && typeof shouldScroll.selector === 'string') { - var el = document.querySelector(shouldScroll.selector); - if (el) { - var offset = shouldScroll.offset && typeof shouldScroll.offset === 'object' ? shouldScroll.offset : {}; - offset = normalizeOffset(offset); - position = getElementPosition(el, offset); - } else if (isValidPosition(shouldScroll)) { - position = normalizePosition(shouldScroll); - } - } else if (isObject && isValidPosition(shouldScroll)) { - position = normalizePosition(shouldScroll); - } - if (position) { - window.scrollTo(position.x, position.y); + if (typeof shouldScroll.then === 'function') { + shouldScroll.then(function (shouldScroll) { + scrollToPosition((shouldScroll), position); + }).catch(function (err) { + if (process.env.NODE_ENV !== 'production') { + assert(false, err.toString()); + } + }); + } else { + scrollToPosition(shouldScroll, position); } }); } @@ -1584,6 +1618,26 @@ function isNumber (v) { return typeof v === 'number' } +function scrollToPosition (shouldScroll, position) { + var isObject = typeof shouldScroll === 'object'; + if (isObject && typeof shouldScroll.selector === 'string') { + var el = document.querySelector(shouldScroll.selector); + if (el) { + var offset = shouldScroll.offset && typeof shouldScroll.offset === 'object' ? shouldScroll.offset : {}; + offset = normalizeOffset(offset); + position = getElementPosition(el, offset); + } else if (isValidPosition(shouldScroll)) { + position = normalizePosition(shouldScroll); + } + } else if (isObject && isValidPosition(shouldScroll)) { + position = normalizePosition(shouldScroll); + } + + if (position) { + window.scrollTo(position.x, position.y); + } +} + /* */ var supportsPushState = inBrowser && (function () { @@ -1679,7 +1733,7 @@ function resolveAsyncComponents (matched) { pending++; var resolve = once(function (resolvedDef) { - if (resolvedDef.__esModule && resolvedDef.default) { + if (isESModule(resolvedDef)) { resolvedDef = resolvedDef.default; } // save resolved on async factory in case it's used elsewhere @@ -1745,6 +1799,14 @@ function flatten (arr) { return Array.prototype.concat.apply([], arr) } +var hasSymbol = + typeof Symbol === 'function' && + typeof Symbol.toStringTag === 'symbol'; + +function isESModule (obj) { + return obj.__esModule || (hasSymbol && obj[Symbol.toStringTag] === 'Module') +} + // 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 @@ -2073,9 +2135,18 @@ var HTML5History = (function (History$$1) { setupScroll(); } + var initLocation = getLocation(this.base); window.addEventListener('popstate', function (e) { var current = this$1.current; - this$1.transitionTo(getLocation(this$1.base), function (route) { + + // Avoiding first `popstate` event dispatched in some browsers but first + // history route not updated since async guard at the same time. + var location = getLocation(this$1.base); + if (this$1.current === START && location === initLocation) { + return + } + + this$1.transitionTo(location, function (route) { if (expectScroll) { handleScroll(router, route, current, true); } @@ -2159,26 +2230,50 @@ var HashHistory = (function (History$$1) { HashHistory.prototype.setupListeners = function setupListeners () { var this$1 = this; - window.addEventListener('hashchange', function () { + var router = this.router; + var expectScroll = router.options.scrollBehavior; + var supportsScroll = supportsPushState && expectScroll; + + if (supportsScroll) { + setupScroll(); + } + + window.addEventListener(supportsPushState ? 'popstate' : 'hashchange', function () { + var current = this$1.current; if (!ensureSlash()) { return } this$1.transitionTo(getHash(), function (route) { - replaceHash(route.fullPath); + if (supportsScroll) { + handleScroll(this$1.router, route, current, true); + } + if (!supportsPushState) { + replaceHash(route.fullPath); + } }); }); }; HashHistory.prototype.push = function push (location, onComplete, onAbort) { + var this$1 = this; + + var ref = this; + var fromRoute = ref.current; this.transitionTo(location, function (route) { pushHash(route.fullPath); + handleScroll(this$1.router, route, fromRoute, false); onComplete && onComplete(route); }, onAbort); }; HashHistory.prototype.replace = function replace (location, onComplete, onAbort) { + var this$1 = this; + + var ref = this; + var fromRoute = ref.current; this.transitionTo(location, function (route) { replaceHash(route.fullPath); + handleScroll(this$1.router, route, fromRoute, false); onComplete && onComplete(route); }, onAbort); }; @@ -2228,15 +2323,27 @@ function getHash () { return index === -1 ? '' : href.slice(index + 1) } +function getUrl (path) { + var href = window.location.href; + var i = href.indexOf('#'); + var base = i >= 0 ? href.slice(0, i) : href; + return (base + "#" + path) +} + function pushHash (path) { - window.location.hash = path; + if (supportsPushState) { + pushState(getUrl(path)); + } else { + window.location.hash = path; + } } function replaceHash (path) { - var href = window.location.href; - var i = href.indexOf('#'); - var base = i >= 0 ? href.slice(0, i) : href; - window.location.replace((base + "#" + path)); + if (supportsPushState) { + replaceState(getUrl(path)); + } else { + window.location.replace(getUrl(path)); + } } /* */ @@ -2338,7 +2445,7 @@ var VueRouter = function VueRouter (options) { } }; -var prototypeAccessors = { currentRoute: {} }; +var prototypeAccessors = { currentRoute: { configurable: true } }; VueRouter.prototype.match = function match ( raw, @@ -2496,7 +2603,7 @@ function createHref (base, fullPath, mode) { } VueRouter.install = install; -VueRouter.version = '2.7.0'; +VueRouter.version = '2.8.0'; if (inBrowser && window.Vue) { window.Vue.use(VueRouter); diff --git a/dist/vue-router.js b/dist/vue-router.js index c7c26bb64..905b8c79a 100644 --- a/dist/vue-router.js +++ b/dist/vue-router.js @@ -1,5 +1,5 @@ /** - * vue-router v2.7.0 + * vue-router v2.8.0 * (c) 2017 Evan You * @license MIT */ @@ -93,7 +93,7 @@ var View = { } } - // also regiseter instance in prepatch hook + // also register instance in prepatch hook // in case the same component instance is reused across different routes ;(data.hook || (data.hook = {})).prepatch = function (_, vnode) { matched.instances[name] = vnode.componentInstance; @@ -101,6 +101,14 @@ var View = { // resolve props data.props = resolveProps(route, matched.props && matched.props[name]); + data.attrs = {}; + + for (var key in data.props) { + if (!('props' in component) || !(key in component.props)) { + data.attrs[key] = data.props[key]; + delete data.props[key]; + } + } return h(component, data, children) } @@ -158,8 +166,7 @@ function resolveQuery ( parsedQuery = {}; } for (var key in extraQuery) { - var val = extraQuery[key]; - parsedQuery[key] = Array.isArray(val) ? val.slice() : val; + parsedQuery[key] = extraQuery[key]; } return parsedQuery } @@ -236,12 +243,18 @@ function createRoute ( router ) { var stringifyQuery$$1 = router && router.options.stringifyQuery; + + var query = location.query || {}; + try { + query = clone(query); + } catch (e) {} + var route = { name: location.name || (record && record.name), meta: (record && record.meta) || {}, path: location.path || '/', hash: location.hash || '', - query: location.query || {}, + query: query, params: location.params || {}, fullPath: getFullPath(location, stringifyQuery$$1), matched: record ? formatMatch(record) : [] @@ -252,6 +265,20 @@ function createRoute ( return Object.freeze(route) } +function clone (value) { + if (Array.isArray(value)) { + return value.map(clone) + } else if (value && typeof value === 'object') { + var res = {}; + for (var key in value) { + res[key] = clone(value[key]); + } + return res + } else { + return value + } +} + // the starting route that represents the initial state var START = createRoute(null, { path: '/' @@ -305,6 +332,8 @@ function isObjectEqual (a, b) { if ( a === void 0 ) a = {}; if ( b === void 0 ) b = {}; + // handle null value #1566 + if (!a || !b) { return a === b } var aKeys = Object.keys(a); var bKeys = Object.keys(b); if (aKeys.length !== bKeys.length) { @@ -484,7 +513,7 @@ function findAnchor (children) { var _Vue; function install (Vue) { - if (install.installed) { return } + if (install.installed && _Vue === Vue) { return } install.installed = true; _Vue = Vue; @@ -606,14 +635,14 @@ function cleanPath (path) { return path.replace(/\/\//g, '/') } -var index$1 = Array.isArray || function (arr) { +var isarray = Array.isArray || function (arr) { return Object.prototype.toString.call(arr) == '[object Array]'; }; /** * Expose `pathToRegexp`. */ -var index = pathToRegexp; +var pathToRegexp_1 = pathToRegexp; var parse_1 = parse; var compile_1 = compile; var tokensToFunction_1 = tokensToFunction; @@ -790,7 +819,7 @@ function tokensToFunction (tokens) { } } - if (index$1(value)) { + if (isarray(value)) { if (!token.repeat) { throw new TypeError('Expected "' + token.name + '" to not repeat, but received `' + JSON.stringify(value) + '`') } @@ -941,7 +970,7 @@ function stringToRegexp (path, keys, options) { * @return {!RegExp} */ function tokensToRegExp (tokens, keys, options) { - if (!index$1(keys)) { + if (!isarray(keys)) { options = /** @type {!Object} */ (keys || options); keys = []; } @@ -1017,7 +1046,7 @@ function tokensToRegExp (tokens, keys, options) { * @return {!RegExp} */ function pathToRegexp (path, keys, options) { - if (!index$1(keys)) { + if (!isarray(keys)) { options = /** @type {!Object} */ (keys || options); keys = []; } @@ -1028,20 +1057,21 @@ function pathToRegexp (path, keys, options) { return regexpToRegexp(path, /** @type {!Array} */ (keys)) } - if (index$1(path)) { + if (isarray(path)) { return arrayToRegexp(/** @type {!Array} */ (path), /** @type {!Array} */ (keys), options) } return stringToRegexp(/** @type {string} */ (path), /** @type {!Array} */ (keys), options) } -index.parse = parse_1; -index.compile = compile_1; -index.tokensToFunction = tokensToFunction_1; -index.tokensToRegExp = tokensToRegExp_1; +pathToRegexp_1.parse = parse_1; +pathToRegexp_1.compile = compile_1; +pathToRegexp_1.tokensToFunction = tokensToFunction_1; +pathToRegexp_1.tokensToRegExp = tokensToRegExp_1; /* */ +// $flow-disable-line var regexpCompileCache = Object.create(null); function fillParams ( @@ -1052,7 +1082,7 @@ function fillParams ( try { var filler = regexpCompileCache[path] || - (regexpCompileCache[path] = index.compile(path)); + (regexpCompileCache[path] = pathToRegexp_1.compile(path)); return filler(params || {}, { pretty: true }) } catch (e) { { @@ -1072,7 +1102,9 @@ function createRouteMap ( ) { // the path list is used to control path matching priority var pathList = oldPathList || []; + // $flow-disable-line var pathMap = oldPathMap || Object.create(null); + // $flow-disable-line var nameMap = oldNameMap || Object.create(null); routes.forEach(function (route) { @@ -1114,8 +1146,12 @@ function addRouteRecord ( ); } - var normalizedPath = normalizePath(path, parent); var pathToRegexpOptions = route.pathToRegexpOptions || {}; + var normalizedPath = normalizePath( + path, + parent, + pathToRegexpOptions.strict + ); if (typeof route.caseSensitive === 'boolean') { pathToRegexpOptions.sensitive = route.caseSensitive; @@ -1203,9 +1239,9 @@ function addRouteRecord ( } function compileRouteRegex (path, pathToRegexpOptions) { - var regex = index(path, [], pathToRegexpOptions); + var regex = pathToRegexp_1(path, [], pathToRegexpOptions); { - var keys = {}; + var keys = Object.create(null); regex.keys.forEach(function (key) { warn(!keys[key.name], ("Duplicate param keys in route with path: \"" + path + "\"")); keys[key.name] = true; @@ -1214,8 +1250,8 @@ function compileRouteRegex (path, pathToRegexpOptions) { return regex } -function normalizePath (path, parent) { - path = path.replace(/\/$/, ''); +function normalizePath (path, parent, strict) { + if (!strict) { path = path.replace(/\/$/, ''); } if (path[0] === '/') { return path } if (parent == null) { return path } return cleanPath(((parent.path) + "/" + path)) @@ -1487,6 +1523,8 @@ function resolveRecordPath (path, record) { var positionStore = Object.create(null); function setupScroll () { + // Fix for #1585 for Firefox + window.history.replaceState({ key: getStateKey() }, ''); window.addEventListener('popstate', function (e) { saveScrollPosition(); if (e.state && e.state.key) { @@ -1518,25 +1556,21 @@ function handleScroll ( router.app.$nextTick(function () { var position = getScrollPosition(); var shouldScroll = behavior(to, from, isPop ? position : null); + if (!shouldScroll) { return } - var isObject = typeof shouldScroll === 'object'; - if (isObject && typeof shouldScroll.selector === 'string') { - var el = document.querySelector(shouldScroll.selector); - if (el) { - var offset = shouldScroll.offset && typeof shouldScroll.offset === 'object' ? shouldScroll.offset : {}; - offset = normalizeOffset(offset); - position = getElementPosition(el, offset); - } else if (isValidPosition(shouldScroll)) { - position = normalizePosition(shouldScroll); - } - } else if (isObject && isValidPosition(shouldScroll)) { - position = normalizePosition(shouldScroll); - } - if (position) { - window.scrollTo(position.x, position.y); + if (typeof shouldScroll.then === 'function') { + shouldScroll.then(function (shouldScroll) { + scrollToPosition((shouldScroll), position); + }).catch(function (err) { + { + assert(false, err.toString()); + } + }); + } else { + scrollToPosition(shouldScroll, position); } }); } @@ -1590,6 +1624,26 @@ function isNumber (v) { return typeof v === 'number' } +function scrollToPosition (shouldScroll, position) { + var isObject = typeof shouldScroll === 'object'; + if (isObject && typeof shouldScroll.selector === 'string') { + var el = document.querySelector(shouldScroll.selector); + if (el) { + var offset = shouldScroll.offset && typeof shouldScroll.offset === 'object' ? shouldScroll.offset : {}; + offset = normalizeOffset(offset); + position = getElementPosition(el, offset); + } else if (isValidPosition(shouldScroll)) { + position = normalizePosition(shouldScroll); + } + } else if (isObject && isValidPosition(shouldScroll)) { + position = normalizePosition(shouldScroll); + } + + if (position) { + window.scrollTo(position.x, position.y); + } +} + /* */ var supportsPushState = inBrowser && (function () { @@ -1685,7 +1739,7 @@ function resolveAsyncComponents (matched) { pending++; var resolve = once(function (resolvedDef) { - if (resolvedDef.__esModule && resolvedDef.default) { + if (isESModule(resolvedDef)) { resolvedDef = resolvedDef.default; } // save resolved on async factory in case it's used elsewhere @@ -1751,6 +1805,14 @@ function flatten (arr) { return Array.prototype.concat.apply([], arr) } +var hasSymbol = + typeof Symbol === 'function' && + typeof Symbol.toStringTag === 'symbol'; + +function isESModule (obj) { + return obj.__esModule || (hasSymbol && obj[Symbol.toStringTag] === 'Module') +} + // 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 @@ -2079,9 +2141,18 @@ var HTML5History = (function (History$$1) { setupScroll(); } + var initLocation = getLocation(this.base); window.addEventListener('popstate', function (e) { var current = this$1.current; - this$1.transitionTo(getLocation(this$1.base), function (route) { + + // Avoiding first `popstate` event dispatched in some browsers but first + // history route not updated since async guard at the same time. + var location = getLocation(this$1.base); + if (this$1.current === START && location === initLocation) { + return + } + + this$1.transitionTo(location, function (route) { if (expectScroll) { handleScroll(router, route, current, true); } @@ -2165,26 +2236,50 @@ var HashHistory = (function (History$$1) { HashHistory.prototype.setupListeners = function setupListeners () { var this$1 = this; - window.addEventListener('hashchange', function () { + var router = this.router; + var expectScroll = router.options.scrollBehavior; + var supportsScroll = supportsPushState && expectScroll; + + if (supportsScroll) { + setupScroll(); + } + + window.addEventListener(supportsPushState ? 'popstate' : 'hashchange', function () { + var current = this$1.current; if (!ensureSlash()) { return } this$1.transitionTo(getHash(), function (route) { - replaceHash(route.fullPath); + if (supportsScroll) { + handleScroll(this$1.router, route, current, true); + } + if (!supportsPushState) { + replaceHash(route.fullPath); + } }); }); }; HashHistory.prototype.push = function push (location, onComplete, onAbort) { + var this$1 = this; + + var ref = this; + var fromRoute = ref.current; this.transitionTo(location, function (route) { pushHash(route.fullPath); + handleScroll(this$1.router, route, fromRoute, false); onComplete && onComplete(route); }, onAbort); }; HashHistory.prototype.replace = function replace (location, onComplete, onAbort) { + var this$1 = this; + + var ref = this; + var fromRoute = ref.current; this.transitionTo(location, function (route) { replaceHash(route.fullPath); + handleScroll(this$1.router, route, fromRoute, false); onComplete && onComplete(route); }, onAbort); }; @@ -2234,15 +2329,27 @@ function getHash () { return index === -1 ? '' : href.slice(index + 1) } +function getUrl (path) { + var href = window.location.href; + var i = href.indexOf('#'); + var base = i >= 0 ? href.slice(0, i) : href; + return (base + "#" + path) +} + function pushHash (path) { - window.location.hash = path; + if (supportsPushState) { + pushState(getUrl(path)); + } else { + window.location.hash = path; + } } function replaceHash (path) { - var href = window.location.href; - var i = href.indexOf('#'); - var base = i >= 0 ? href.slice(0, i) : href; - window.location.replace((base + "#" + path)); + if (supportsPushState) { + replaceState(getUrl(path)); + } else { + window.location.replace(getUrl(path)); + } } /* */ @@ -2344,7 +2451,7 @@ var VueRouter = function VueRouter (options) { } }; -var prototypeAccessors = { currentRoute: {} }; +var prototypeAccessors = { currentRoute: { configurable: true } }; VueRouter.prototype.match = function match ( raw, @@ -2502,7 +2609,7 @@ function createHref (base, fullPath, mode) { } VueRouter.install = install; -VueRouter.version = '2.7.0'; +VueRouter.version = '2.8.0'; if (inBrowser && window.Vue) { window.Vue.use(VueRouter); diff --git a/dist/vue-router.min.js b/dist/vue-router.min.js index 4f71c8057..1d343cf02 100644 --- a/dist/vue-router.min.js +++ b/dist/vue-router.min.js @@ -1,6 +1,6 @@ /** - * vue-router v2.7.0 + * vue-router v2.8.0 * (c) 2017 Evan You * @license MIT */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.VueRouter=e()}(this,function(){"use strict";function t(t,e){}function e(t){return Object.prototype.toString.call(t).indexOf("Error")>-1}function r(t,e){switch(typeof e){case"undefined":return;case"object":return e;case"function":return e(t);case"boolean":return e?t.params:void 0}}function n(t,e,r){void 0===e&&(e={});var n,i=r||o;try{n=i(t||"")}catch(t){n={}}for(var a in e){var u=e[a];n[a]=Array.isArray(u)?u.slice():u}return n}function o(t){var e={};return(t=t.trim().replace(/^(\?|#|&)/,""))?(t.split("&").forEach(function(t){var r=t.replace(/\+/g," ").split("="),n=$t(r.shift()),o=r.length>0?$t(r.join("=")):null;void 0===e[n]?e[n]=o:Array.isArray(e[n])?e[n].push(o):e[n]=[e[n],o]}),e):e}function i(t){var e=t?Object.keys(t).map(function(e){var r=t[e];if(void 0===r)return"";if(null===r)return Tt(e);if(Array.isArray(r)){var n=[];return r.forEach(function(t){void 0!==t&&(null===t?n.push(Tt(e)):n.push(Tt(e)+"="+Tt(t)))}),n.join("&")}return Tt(e)+"="+Tt(r)}).filter(function(t){return t.length>0}).join("&"):null;return e?"?"+e:""}function a(t,e,r,n){var o=n&&n.options.stringifyQuery,i={name:e.name||t&&t.name,meta:t&&t.meta||{},path:e.path||"/",hash:e.hash||"",query:e.query||{},params:e.params||{},fullPath:c(e,o),matched:t?u(t):[]};return r&&(i.redirectedFrom=c(r,o)),Object.freeze(i)}function u(t){for(var e=[];t;)e.unshift(t),t=t.parent;return e}function c(t,e){var r=t.path,n=t.query;void 0===n&&(n={});var o=t.hash;void 0===o&&(o="");var a=e||i;return(r||"/")+a(n)+o}function s(t,e){return e===qt?t===e:!!e&&(t.path&&e.path?t.path.replace(St,"")===e.path.replace(St,"")&&t.hash===e.hash&&p(t.query,e.query):!(!t.name||!e.name)&&(t.name===e.name&&t.hash===e.hash&&p(t.query,e.query)&&p(t.params,e.params)))}function p(t,e){void 0===t&&(t={}),void 0===e&&(e={});var r=Object.keys(t),n=Object.keys(e);return r.length===n.length&&r.every(function(r){var n=t[r],o=e[r];return"object"==typeof n&&"object"==typeof o?p(n,o):String(n)===String(o)})}function f(t,e){return 0===t.path.replace(St,"/").indexOf(e.path.replace(St,"/"))&&(!e.hash||t.hash===e.hash)&&h(t.query,e.query)}function h(t,e){for(var r in e)if(!(r in t))return!1;return!0}function l(t){if(!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey||t.defaultPrevented||void 0!==t.button&&0!==t.button)){if(t.currentTarget&&t.currentTarget.getAttribute){var e=t.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(e))return}return t.preventDefault&&t.preventDefault(),!0}}function d(t){if(t)for(var e,r=0;r=0&&(e=t.slice(n),t=t.slice(0,n));var o=t.indexOf("?");return o>=0&&(r=t.slice(o+1),t=t.slice(0,o)),{path:t,query:r,hash:e}}function g(t){return t.replace(/\/\//g,"/")}function b(t,e){for(var r,n=[],o=0,i=0,a="",u=e&&e.delimiter||"/";null!=(r=Ft.exec(t));){var c=r[0],s=r[1],p=r.index;if(a+=t.slice(i,p),i=p+c.length,s)a+=s[1];else{var f=t[i],h=r[2],l=r[3],d=r[4],y=r[5],v=r[6],m=r[7];a&&(n.push(a),a="");var g=null!=h&&null!=f&&f!==h,b="+"===v||"*"===v,w="?"===v||"*"===v,x=r[2]||u,k=d||y;n.push({name:l||o++,prefix:h||"",delimiter:x,optional:w,repeat:b,partial:g,asterisk:!!m,pattern:k?E(k):m?".*":"[^"+R(x)+"]+?"})}}return i-1&&(o.params[h]=r.params[h]);if(u)return o.path=S(u.path,o.params,'named route "'+a+'"'),i(u,o,n)}else if(o.path){o.params={};for(var l=0;l=t.length?r():t[o]?e(t[o],function(){n(o+1)}):n(o+1)};n(0)}function nt(t){return function(r,n,o){var i=!1,a=0,u=null;ot(t,function(t,r,n,c){if("function"==typeof t&&void 0===t.cid){i=!0,a++;var s,p=at(function(e){e.__esModule&&e.default&&(e=e.default),t.resolved="function"==typeof e?e:Ot.extend(e),n.components[c]=e,--a<=0&&o()}),f=at(function(t){var r="Failed to resolve async component "+c+": "+t;u||(u=e(t)?t:new Error(r),o(u))});try{s=t(p,f)}catch(t){f(t)}if(s)if("function"==typeof s.then)s.then(p,f);else{var h=s.component;h&&"function"==typeof h.then&&h.then(p,f)}}}),i||o()}}function ot(t,e){return it(t.map(function(t){return Object.keys(t.components).map(function(r){return e(t.components[r],t.instances[r],t,r)})}))}function it(t){return Array.prototype.concat.apply([],t)}function at(t){var e=!1;return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];if(!e)return e=!0,t.apply(this,r)}}function ut(t){if(!t)if(Ht){var e=document.querySelector("base");t=(t=e&&e.getAttribute("href")||"/").replace(/^https?:\/\/[^\/]+/,"")}else t="/";return"/"!==t.charAt(0)&&(t="/"+t),t.replace(/\/$/,"")}function ct(t,e){var r,n=Math.max(t.length,e.length);for(r=0;r=0?e.slice(0,r):e;window.location.replace(n+"#"+t)}function Rt(t,e){return t.push(e),function(){var r=t.indexOf(e);r>-1&&t.splice(r,1)}}function Et(t,e,r){var n="hash"===r?"#"+e:e;return t?g(t+"/"+n):n}var Ot,Ct={name:"router-view",functional:!0,props:{name:{type:String,default:"default"}},render:function(t,e){var n=e.props,o=e.children,i=e.parent,a=e.data;a.routerView=!0;for(var u=i.$createElement,c=n.name,s=i.$route,p=i._routerViewCache||(i._routerViewCache={}),f=0,h=!1;i&&i._routerRoot!==i;)i.$vnode&&i.$vnode.data.routerView&&f++,i._inactive&&(h=!0),i=i.$parent;if(a.routerViewDepth=f,h)return u(p[c],a,o);var l=s.matched[f];if(!l)return p[c]=null,u();var d=p[c]=l.components[c];return a.registerRouteInstance=function(t,e){var r=l.instances[c];(e&&r!==t||!e&&r===t)&&(l.instances[c]=e)},(a.hook||(a.hook={})).prepatch=function(t,e){l.instances[c]=e.componentInstance},a.props=r(s,l.props&&l.props[c]),u(d,a,o)}},At=/[!'()*]/g,jt=function(t){return"%"+t.charCodeAt(0).toString(16)},_t=/%2C/g,Tt=function(t){return encodeURIComponent(t).replace(At,jt).replace(_t,",")},$t=decodeURIComponent,St=/\/?$/,qt=a(null,{path:"/"}),Lt=[String,Object],Pt=[String,Array],Ut={name:"router-link",props:{to:{type:Lt,required:!0},tag:{type:String,default:"a"},exact:Boolean,append:Boolean,replace:Boolean,activeClass:String,exactActiveClass:String,event:{type:Pt,default:"click"}},render:function(t){var e=this,r=this.$router,n=this.$route,o=r.resolve(this.to,n,this.append),i=o.location,u=o.route,c=o.href,p={},h=r.options.linkActiveClass,y=r.options.linkExactActiveClass,v=null==h?"router-link-active":h,m=null==y?"router-link-exact-active":y,g=null==this.activeClass?v:this.activeClass,b=null==this.exactActiveClass?m:this.exactActiveClass,w=i.path?a(null,i,null,r):u;p[b]=s(n,w),p[g]=this.exact?p[b]:f(n,w);var x=function(t){l(t)&&(e.replace?r.replace(i):r.push(i))},k={click:l};Array.isArray(this.event)?this.event.forEach(function(t){k[t]=x}):k[this.event]=x;var R={class:p};if("a"===this.tag)R.on=k,R.attrs={href:c};else{var E=d(this.$slots.default);if(E){E.isStatic=!1;var O=Ot.util.extend;(E.data=O({},E.data)).on=k,(E.data.attrs=O({},E.data.attrs)).href=c}else R.on=k}return t(this.tag,R,this.$slots.default)}},Ht="undefined"!=typeof window,It=Array.isArray||function(t){return"[object Array]"==Object.prototype.toString.call(t)},Mt=$,Vt=b,zt=k,Bt=T,Ft=new RegExp(["(\\\\.)","([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))"].join("|"),"g");Mt.parse=Vt,Mt.compile=function(t,e){return k(b(t,e))},Mt.tokensToFunction=zt,Mt.tokensToRegExp=Bt;var Dt=Object.create(null),Kt=Object.create(null),Jt=Ht&&function(){var t=window.navigator.userAgent;return(-1===t.indexOf("Android 2.")&&-1===t.indexOf("Android 4.0")||-1===t.indexOf("Mobile Safari")||-1!==t.indexOf("Chrome")||-1!==t.indexOf("Windows Phone"))&&(window.history&&"pushState"in window.history)}(),Nt=Ht&&window.performance&&window.performance.now?window.performance:Date,Qt=W(),Xt=function(t,e){this.router=t,this.base=ut(e),this.current=qt,this.pending=null,this.ready=!1,this.readyCbs=[],this.readyErrorCbs=[],this.errorCbs=[]};Xt.prototype.listen=function(t){this.cb=t},Xt.prototype.onReady=function(t,e){this.ready?t():(this.readyCbs.push(t),e&&this.readyErrorCbs.push(e))},Xt.prototype.onError=function(t){this.errorCbs.push(t)},Xt.prototype.transitionTo=function(t,e,r){var n=this,o=this.router.match(t,this.current);this.confirmTransition(o,function(){n.updateRoute(o),e&&e(o),n.ensureURL(),n.ready||(n.ready=!0,n.readyCbs.forEach(function(t){t(o)}))},function(t){r&&r(t),t&&!n.ready&&(n.ready=!0,n.readyErrorCbs.forEach(function(e){e(t)}))})},Xt.prototype.confirmTransition=function(r,n,o){var i=this,a=this.current,u=function(r){e(r)&&(i.errorCbs.length?i.errorCbs.forEach(function(t){t(r)}):(t(!1,"uncaught error during route navigation:"),console.error(r))),o&&o(r)};if(s(r,a)&&r.matched.length===a.matched.length)return this.ensureURL(),u();var c=ct(this.current.matched,r.matched),p=c.updated,f=c.deactivated,h=c.activated,l=[].concat(ft(f),this.router.beforeHooks,ht(p),h.map(function(t){return t.beforeEnter}),nt(h));this.pending=r;var d=function(t,n){if(i.pending!==r)return u();try{t(r,a,function(t){!1===t||e(t)?(i.ensureURL(!0),u(t)):"string"==typeof t||"object"==typeof t&&("string"==typeof t.path||"string"==typeof t.name)?(u(),"object"==typeof t&&t.replace?i.replace(t):i.push(t)):n(t)})}catch(t){u(t)}};rt(l,d,function(){var t=[];rt(dt(h,t,function(){return i.current===r}).concat(i.router.resolveHooks),d,function(){if(i.pending!==r)return u();i.pending=null,n(r),i.router.app&&i.router.app.$nextTick(function(){t.forEach(function(t){t()})})})})},Xt.prototype.updateRoute=function(t){var e=this.current;this.current=t,this.cb&&this.cb(t),this.router.afterHooks.forEach(function(r){r&&r(t,e)})};var Yt=function(t){function e(e,r){var n=this;t.call(this,e,r);var o=e.options.scrollBehavior;o&&B(),window.addEventListener("popstate",function(t){var r=n.current;n.transitionTo(mt(n.base),function(t){o&&F(e,t,r,!0)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.go=function(t){window.history.go(t)},e.prototype.push=function(t,e,r){var n=this,o=this.current;this.transitionTo(t,function(t){tt(g(n.base+t.fullPath)),F(n.router,t,o,!1),e&&e(t)},r)},e.prototype.replace=function(t,e,r){var n=this,o=this.current;this.transitionTo(t,function(t){et(g(n.base+t.fullPath)),F(n.router,t,o,!1),e&&e(t)},r)},e.prototype.ensureURL=function(t){if(mt(this.base)!==this.current.fullPath){var e=g(this.base+this.current.fullPath);t?tt(e):et(e)}},e.prototype.getCurrentLocation=function(){return mt(this.base)},e}(Xt),Wt=function(t){function e(e,r,n){t.call(this,e,r),n&>(this.base)||bt()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.setupListeners=function(){var t=this;window.addEventListener("hashchange",function(){bt()&&t.transitionTo(wt(),function(t){kt(t.fullPath)})})},e.prototype.push=function(t,e,r){this.transitionTo(t,function(t){xt(t.fullPath),e&&e(t)},r)},e.prototype.replace=function(t,e,r){this.transitionTo(t,function(t){kt(t.fullPath),e&&e(t)},r)},e.prototype.go=function(t){window.history.go(t)},e.prototype.ensureURL=function(t){var e=this.current.fullPath;wt()!==e&&(t?xt(e):kt(e))},e.prototype.getCurrentLocation=function(){return wt()},e}(Xt),Gt=function(t){function e(e,r){t.call(this,e,r),this.stack=[],this.index=-1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.push=function(t,e,r){var n=this;this.transitionTo(t,function(t){n.stack=n.stack.slice(0,n.index+1).concat(t),n.index++,e&&e(t)},r)},e.prototype.replace=function(t,e,r){var n=this;this.transitionTo(t,function(t){n.stack=n.stack.slice(0,n.index).concat(t),e&&e(t)},r)},e.prototype.go=function(t){var e=this,r=this.index+t;if(!(r<0||r>=this.stack.length)){var n=this.stack[r];this.confirmTransition(n,function(){e.index=r,e.updateRoute(n)})}},e.prototype.getCurrentLocation=function(){var t=this.stack[this.stack.length-1];return t?t.fullPath:"/"},e.prototype.ensureURL=function(){},e}(Xt),Zt=function(t){void 0===t&&(t={}),this.app=null,this.apps=[],this.options=t,this.beforeHooks=[],this.resolveHooks=[],this.afterHooks=[],this.matcher=M(t.routes||[],this);var e=t.mode||"hash";switch(this.fallback="history"===e&&!Jt&&!1!==t.fallback,this.fallback&&(e="hash"),Ht||(e="abstract"),this.mode=e,e){case"history":this.history=new Yt(this,t.base);break;case"hash":this.history=new Wt(this,t.base,this.fallback);break;case"abstract":this.history=new Gt(this,t.base)}},te={currentRoute:{}};return Zt.prototype.match=function(t,e,r){return this.matcher.match(t,e,r)},te.currentRoute.get=function(){return this.history&&this.history.current},Zt.prototype.init=function(t){var e=this;if(this.apps.push(t),!this.app){this.app=t;var r=this.history;if(r instanceof Yt)r.transitionTo(r.getCurrentLocation());else if(r instanceof Wt){var n=function(){r.setupListeners()};r.transitionTo(r.getCurrentLocation(),n,n)}r.listen(function(t){e.apps.forEach(function(e){e._route=t})})}},Zt.prototype.beforeEach=function(t){return Rt(this.beforeHooks,t)},Zt.prototype.beforeResolve=function(t){return Rt(this.resolveHooks,t)},Zt.prototype.afterEach=function(t){return Rt(this.afterHooks,t)},Zt.prototype.onReady=function(t,e){this.history.onReady(t,e)},Zt.prototype.onError=function(t){this.history.onError(t)},Zt.prototype.push=function(t,e,r){this.history.push(t,e,r)},Zt.prototype.replace=function(t,e,r){this.history.replace(t,e,r)},Zt.prototype.go=function(t){this.history.go(t)},Zt.prototype.back=function(){this.go(-1)},Zt.prototype.forward=function(){this.go(1)},Zt.prototype.getMatchedComponents=function(t){var e=t?t.matched?t:this.resolve(t).route:this.currentRoute;return e?[].concat.apply([],e.matched.map(function(t){return Object.keys(t.components).map(function(e){return t.components[e]})})):[]},Zt.prototype.resolve=function(t,e,r){var n=H(t,e||this.history.current,r,this),o=this.match(n,e),i=o.redirectedFrom||o.fullPath;return{location:n,route:o,href:Et(this.history.base,i,this.mode),normalizedTo:n,resolved:o}},Zt.prototype.addRoutes=function(t){this.matcher.addRoutes(t),this.history.current!==qt&&this.history.transitionTo(this.history.getCurrentLocation())},Object.defineProperties(Zt.prototype,te),Zt.install=y,Zt.version="2.7.0",Ht&&window.Vue&&window.Vue.use(Zt),Zt}); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.VueRouter=e()}(this,function(){"use strict";function t(t,e){}function e(t){return Object.prototype.toString.call(t).indexOf("Error")>-1}function r(t,e){switch(typeof e){case"undefined":return;case"object":return e;case"function":return e(t);case"boolean":return e?t.params:void 0}}function n(t,e,r){void 0===e&&(e={});var n,i=r||o;try{n=i(t||"")}catch(t){n={}}for(var a in e)n[a]=e[a];return n}function o(t){var e={};return(t=t.trim().replace(/^(\?|#|&)/,""))?(t.split("&").forEach(function(t){var r=t.replace(/\+/g," ").split("="),n=Pt(r.shift()),o=r.length>0?Pt(r.join("=")):null;void 0===e[n]?e[n]=o:Array.isArray(e[n])?e[n].push(o):e[n]=[e[n],o]}),e):e}function i(t){var e=t?Object.keys(t).map(function(e){var r=t[e];if(void 0===r)return"";if(null===r)return Lt(e);if(Array.isArray(r)){var n=[];return r.forEach(function(t){void 0!==t&&(null===t?n.push(Lt(e)):n.push(Lt(e)+"="+Lt(t)))}),n.join("&")}return Lt(e)+"="+Lt(r)}).filter(function(t){return t.length>0}).join("&"):null;return e?"?"+e:""}function a(t,e,r,n){var o=n&&n.options.stringifyQuery,i=e.query||{};try{i=u(i)}catch(t){}var a={name:e.name||t&&t.name,meta:t&&t.meta||{},path:e.path||"/",hash:e.hash||"",query:i,params:e.params||{},fullPath:s(e,o),matched:t?c(t):[]};return r&&(a.redirectedFrom=s(r,o)),Object.freeze(a)}function u(t){if(Array.isArray(t))return t.map(u);if(t&&"object"==typeof t){var e={};for(var r in t)e[r]=u(t[r]);return e}return t}function c(t){for(var e=[];t;)e.unshift(t),t=t.parent;return e}function s(t,e){var r=t.path,n=t.query;void 0===n&&(n={});var o=t.hash;void 0===o&&(o="");var a=e||i;return(r||"/")+a(n)+o}function p(t,e){return e===Mt?t===e:!!e&&(t.path&&e.path?t.path.replace(Ut,"")===e.path.replace(Ut,"")&&t.hash===e.hash&&f(t.query,e.query):!(!t.name||!e.name)&&(t.name===e.name&&t.hash===e.hash&&f(t.query,e.query)&&f(t.params,e.params)))}function f(t,e){if(void 0===t&&(t={}),void 0===e&&(e={}),!t||!e)return t===e;var r=Object.keys(t),n=Object.keys(e);return r.length===n.length&&r.every(function(r){var n=t[r],o=e[r];return"object"==typeof n&&"object"==typeof o?f(n,o):String(n)===String(o)})}function h(t,e){return 0===t.path.replace(Ut,"/").indexOf(e.path.replace(Ut,"/"))&&(!e.hash||t.hash===e.hash)&&l(t.query,e.query)}function l(t,e){for(var r in e)if(!(r in t))return!1;return!0}function d(t){if(!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey||t.defaultPrevented||void 0!==t.button&&0!==t.button)){if(t.currentTarget&&t.currentTarget.getAttribute){var e=t.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(e))return}return t.preventDefault&&t.preventDefault(),!0}}function y(t){if(t)for(var e,r=0;r=0&&(e=t.slice(n),t=t.slice(0,n));var o=t.indexOf("?");return o>=0&&(r=t.slice(o+1),t=t.slice(0,o)),{path:t,query:r,hash:e}}function b(t){return t.replace(/\/\//g,"/")}function w(t,e){for(var r,n=[],o=0,i=0,a="",u=e&&e.delimiter||"/";null!=(r=Nt.exec(t));){var c=r[0],s=r[1],p=r.index;if(a+=t.slice(i,p),i=p+c.length,s)a+=s[1];else{var f=t[i],h=r[2],l=r[3],d=r[4],y=r[5],v=r[6],m=r[7];a&&(n.push(a),a="");var g=null!=h&&null!=f&&f!==h,b="+"===v||"*"===v,w="?"===v||"*"===v,x=r[2]||u,k=d||y;n.push({name:l||o++,prefix:h||"",delimiter:x,optional:w,repeat:b,partial:g,asterisk:!!m,pattern:k?O(k):m?".*":"[^"+E(x)+"]+?"})}}return i-1&&(o.params[h]=r.params[h]);if(u)return o.path=q(u.path,o.params,'named route "'+a+'"'),i(u,o,n)}else if(o.path){o.params={};for(var l=0;l=t.length?r():t[o]?e(t[o],function(){n(o+1)}):n(o+1)};n(0)}function it(t){return function(r,n,o){var i=!1,a=0,u=null;at(t,function(t,r,n,c){if("function"==typeof t&&void 0===t.cid){i=!0,a++;var s,p=st(function(e){ct(e)&&(e=e.default),t.resolved="function"==typeof e?e:_t.extend(e),n.components[c]=e,--a<=0&&o()}),f=st(function(t){var r="Failed to resolve async component "+c+": "+t;u||(u=e(t)?t:new Error(r),o(u))});try{s=t(p,f)}catch(t){f(t)}if(s)if("function"==typeof s.then)s.then(p,f);else{var h=s.component;h&&"function"==typeof h.then&&h.then(p,f)}}}),i||o()}}function at(t,e){return ut(t.map(function(t){return Object.keys(t.components).map(function(r){return e(t.components[r],t.instances[r],t,r)})}))}function ut(t){return Array.prototype.concat.apply([],t)}function ct(t){return t.__esModule||Zt&&"Module"===t[Symbol.toStringTag]}function st(t){var e=!1;return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];if(!e)return e=!0,t.apply(this,r)}}function pt(t){if(!t)if(zt){var e=document.querySelector("base");t=(t=e&&e.getAttribute("href")||"/").replace(/^https?:\/\/[^\/]+/,"")}else t="/";return"/"!==t.charAt(0)&&(t="/"+t),t.replace(/\/$/,"")}function ft(t,e){var r,n=Math.max(t.length,e.length);for(r=0;r=0?e.slice(0,r):e)+"#"+t}function Ot(t){Yt?rt(Et(t)):window.location.hash=t}function Ct(t){Yt?nt(Et(t)):window.location.replace(Et(t))}function jt(t,e){return t.push(e),function(){var r=t.indexOf(e);r>-1&&t.splice(r,1)}}function At(t,e,r){var n="hash"===r?"#"+e:e;return t?b(t+"/"+n):n}var _t,Tt={name:"router-view",functional:!0,props:{name:{type:String,default:"default"}},render:function(t,e){var n=e.props,o=e.children,i=e.parent,a=e.data;a.routerView=!0;for(var u=i.$createElement,c=n.name,s=i.$route,p=i._routerViewCache||(i._routerViewCache={}),f=0,h=!1;i&&i._routerRoot!==i;)i.$vnode&&i.$vnode.data.routerView&&f++,i._inactive&&(h=!0),i=i.$parent;if(a.routerViewDepth=f,h)return u(p[c],a,o);var l=s.matched[f];if(!l)return p[c]=null,u();var d=p[c]=l.components[c];a.registerRouteInstance=function(t,e){var r=l.instances[c];(e&&r!==t||!e&&r===t)&&(l.instances[c]=e)},(a.hook||(a.hook={})).prepatch=function(t,e){l.instances[c]=e.componentInstance},a.props=r(s,l.props&&l.props[c]),a.attrs={};for(var y in a.props)"props"in d&&y in d.props||(a.attrs[y]=a.props[y],delete a.props[y]);return u(d,a,o)}},St=/[!'()*]/g,$t=function(t){return"%"+t.charCodeAt(0).toString(16)},qt=/%2C/g,Lt=function(t){return encodeURIComponent(t).replace(St,$t).replace(qt,",")},Pt=decodeURIComponent,Ut=/\/?$/,Mt=a(null,{path:"/"}),Ht=[String,Object],It=[String,Array],Vt={name:"router-link",props:{to:{type:Ht,required:!0},tag:{type:String,default:"a"},exact:Boolean,append:Boolean,replace:Boolean,activeClass:String,exactActiveClass:String,event:{type:It,default:"click"}},render:function(t){var e=this,r=this.$router,n=this.$route,o=r.resolve(this.to,n,this.append),i=o.location,u=o.route,c=o.href,s={},f=r.options.linkActiveClass,l=r.options.linkExactActiveClass,v=null==f?"router-link-active":f,m=null==l?"router-link-exact-active":l,g=null==this.activeClass?v:this.activeClass,b=null==this.exactActiveClass?m:this.exactActiveClass,w=i.path?a(null,i,null,r):u;s[b]=p(n,w),s[g]=this.exact?s[b]:h(n,w);var x=function(t){d(t)&&(e.replace?r.replace(i):r.push(i))},k={click:d};Array.isArray(this.event)?this.event.forEach(function(t){k[t]=x}):k[this.event]=x;var R={class:s};if("a"===this.tag)R.on=k,R.attrs={href:c};else{var E=y(this.$slots.default);if(E){E.isStatic=!1;var O=_t.util.extend;(E.data=O({},E.data)).on=k,(E.data.attrs=O({},E.data.attrs)).href=c}else R.on=k}return t(this.tag,R,this.$slots.default)}},zt="undefined"!=typeof window,Bt=Array.isArray||function(t){return"[object Array]"==Object.prototype.toString.call(t)},Ft=$,Dt=w,Kt=R,Jt=S,Nt=new RegExp(["(\\\\.)","([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))"].join("|"),"g");Ft.parse=Dt,Ft.compile=function(t,e){return R(w(t,e))},Ft.tokensToFunction=Kt,Ft.tokensToRegExp=Jt;var Qt=Object.create(null),Xt=Object.create(null),Yt=zt&&function(){var t=window.navigator.userAgent;return(-1===t.indexOf("Android 2.")&&-1===t.indexOf("Android 4.0")||-1===t.indexOf("Mobile Safari")||-1!==t.indexOf("Chrome")||-1!==t.indexOf("Windows Phone"))&&(window.history&&"pushState"in window.history)}(),Wt=zt&&window.performance&&window.performance.now?window.performance:Date,Gt=Z(),Zt="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag,te=function(t,e){this.router=t,this.base=pt(e),this.current=Mt,this.pending=null,this.ready=!1,this.readyCbs=[],this.readyErrorCbs=[],this.errorCbs=[]};te.prototype.listen=function(t){this.cb=t},te.prototype.onReady=function(t,e){this.ready?t():(this.readyCbs.push(t),e&&this.readyErrorCbs.push(e))},te.prototype.onError=function(t){this.errorCbs.push(t)},te.prototype.transitionTo=function(t,e,r){var n=this,o=this.router.match(t,this.current);this.confirmTransition(o,function(){n.updateRoute(o),e&&e(o),n.ensureURL(),n.ready||(n.ready=!0,n.readyCbs.forEach(function(t){t(o)}))},function(t){r&&r(t),t&&!n.ready&&(n.ready=!0,n.readyErrorCbs.forEach(function(e){e(t)}))})},te.prototype.confirmTransition=function(r,n,o){var i=this,a=this.current,u=function(r){e(r)&&(i.errorCbs.length?i.errorCbs.forEach(function(t){t(r)}):(t(!1,"uncaught error during route navigation:"),console.error(r))),o&&o(r)};if(p(r,a)&&r.matched.length===a.matched.length)return this.ensureURL(),u();var c=ft(this.current.matched,r.matched),s=c.updated,f=c.deactivated,h=c.activated,l=[].concat(dt(f),this.router.beforeHooks,yt(s),h.map(function(t){return t.beforeEnter}),it(h));this.pending=r;var d=function(t,n){if(i.pending!==r)return u();try{t(r,a,function(t){!1===t||e(t)?(i.ensureURL(!0),u(t)):"string"==typeof t||"object"==typeof t&&("string"==typeof t.path||"string"==typeof t.name)?(u(),"object"==typeof t&&t.replace?i.replace(t):i.push(t)):n(t)})}catch(t){u(t)}};ot(l,d,function(){var t=[];ot(mt(h,t,function(){return i.current===r}).concat(i.router.resolveHooks),d,function(){if(i.pending!==r)return u();i.pending=null,n(r),i.router.app&&i.router.app.$nextTick(function(){t.forEach(function(t){t()})})})})},te.prototype.updateRoute=function(t){var e=this.current;this.current=t,this.cb&&this.cb(t),this.router.afterHooks.forEach(function(r){r&&r(t,e)})};var ee=function(t){function e(e,r){var n=this;t.call(this,e,r);var o=e.options.scrollBehavior;o&&F();var i=wt(this.base);window.addEventListener("popstate",function(t){var r=n.current,a=wt(n.base);n.current===Mt&&a===i||n.transitionTo(a,function(t){o&&D(e,t,r,!0)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.go=function(t){window.history.go(t)},e.prototype.push=function(t,e,r){var n=this,o=this.current;this.transitionTo(t,function(t){rt(b(n.base+t.fullPath)),D(n.router,t,o,!1),e&&e(t)},r)},e.prototype.replace=function(t,e,r){var n=this,o=this.current;this.transitionTo(t,function(t){nt(b(n.base+t.fullPath)),D(n.router,t,o,!1),e&&e(t)},r)},e.prototype.ensureURL=function(t){if(wt(this.base)!==this.current.fullPath){var e=b(this.base+this.current.fullPath);t?rt(e):nt(e)}},e.prototype.getCurrentLocation=function(){return wt(this.base)},e}(te),re=function(t){function e(e,r,n){t.call(this,e,r),n&&xt(this.base)||kt()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.setupListeners=function(){var t=this,e=this.router.options.scrollBehavior,r=Yt&&e;r&&F(),window.addEventListener(Yt?"popstate":"hashchange",function(){var e=t.current;kt()&&t.transitionTo(Rt(),function(n){r&&D(t.router,n,e,!0),Yt||Ct(n.fullPath)})})},e.prototype.push=function(t,e,r){var n=this,o=this.current;this.transitionTo(t,function(t){Ot(t.fullPath),D(n.router,t,o,!1),e&&e(t)},r)},e.prototype.replace=function(t,e,r){var n=this,o=this.current;this.transitionTo(t,function(t){Ct(t.fullPath),D(n.router,t,o,!1),e&&e(t)},r)},e.prototype.go=function(t){window.history.go(t)},e.prototype.ensureURL=function(t){var e=this.current.fullPath;Rt()!==e&&(t?Ot(e):Ct(e))},e.prototype.getCurrentLocation=function(){return Rt()},e}(te),ne=function(t){function e(e,r){t.call(this,e,r),this.stack=[],this.index=-1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.push=function(t,e,r){var n=this;this.transitionTo(t,function(t){n.stack=n.stack.slice(0,n.index+1).concat(t),n.index++,e&&e(t)},r)},e.prototype.replace=function(t,e,r){var n=this;this.transitionTo(t,function(t){n.stack=n.stack.slice(0,n.index).concat(t),e&&e(t)},r)},e.prototype.go=function(t){var e=this,r=this.index+t;if(!(r<0||r>=this.stack.length)){var n=this.stack[r];this.confirmTransition(n,function(){e.index=r,e.updateRoute(n)})}},e.prototype.getCurrentLocation=function(){var t=this.stack[this.stack.length-1];return t?t.fullPath:"/"},e.prototype.ensureURL=function(){},e}(te),oe=function(t){void 0===t&&(t={}),this.app=null,this.apps=[],this.options=t,this.beforeHooks=[],this.resolveHooks=[],this.afterHooks=[],this.matcher=V(t.routes||[],this);var e=t.mode||"hash";switch(this.fallback="history"===e&&!Yt&&!1!==t.fallback,this.fallback&&(e="hash"),zt||(e="abstract"),this.mode=e,e){case"history":this.history=new ee(this,t.base);break;case"hash":this.history=new re(this,t.base,this.fallback);break;case"abstract":this.history=new ne(this,t.base)}},ie={currentRoute:{configurable:!0}};return oe.prototype.match=function(t,e,r){return this.matcher.match(t,e,r)},ie.currentRoute.get=function(){return this.history&&this.history.current},oe.prototype.init=function(t){var e=this;if(this.apps.push(t),!this.app){this.app=t;var r=this.history;if(r instanceof ee)r.transitionTo(r.getCurrentLocation());else if(r instanceof re){var n=function(){r.setupListeners()};r.transitionTo(r.getCurrentLocation(),n,n)}r.listen(function(t){e.apps.forEach(function(e){e._route=t})})}},oe.prototype.beforeEach=function(t){return jt(this.beforeHooks,t)},oe.prototype.beforeResolve=function(t){return jt(this.resolveHooks,t)},oe.prototype.afterEach=function(t){return jt(this.afterHooks,t)},oe.prototype.onReady=function(t,e){this.history.onReady(t,e)},oe.prototype.onError=function(t){this.history.onError(t)},oe.prototype.push=function(t,e,r){this.history.push(t,e,r)},oe.prototype.replace=function(t,e,r){this.history.replace(t,e,r)},oe.prototype.go=function(t){this.history.go(t)},oe.prototype.back=function(){this.go(-1)},oe.prototype.forward=function(){this.go(1)},oe.prototype.getMatchedComponents=function(t){var e=t?t.matched?t:this.resolve(t).route:this.currentRoute;return e?[].concat.apply([],e.matched.map(function(t){return Object.keys(t.components).map(function(e){return t.components[e]})})):[]},oe.prototype.resolve=function(t,e,r){var n=H(t,e||this.history.current,r,this),o=this.match(n,e),i=o.redirectedFrom||o.fullPath;return{location:n,route:o,href:At(this.history.base,i,this.mode),normalizedTo:n,resolved:o}},oe.prototype.addRoutes=function(t){this.matcher.addRoutes(t),this.history.current!==Mt&&this.history.transitionTo(this.history.getCurrentLocation())},Object.defineProperties(oe.prototype,ie),oe.install=v,oe.version="2.8.0",zt&&window.Vue&&window.Vue.use(oe),oe}); \ No newline at end of file