From a3299382657e7d98b12720c647c36a123f79c5c5 Mon Sep 17 00:00:00 2001 From: Evan You Date: Sat, 17 Jun 2017 23:58:11 +0800 Subject: [PATCH] [build] 2.6.0 --- dist/vue-router.common.js | 122 ++++++++++++++++++++++++-------------- dist/vue-router.esm.js | 122 ++++++++++++++++++++++++-------------- dist/vue-router.js | 122 ++++++++++++++++++++++++-------------- dist/vue-router.min.js | 4 +- 4 files changed, 239 insertions(+), 131 deletions(-) diff --git a/dist/vue-router.common.js b/dist/vue-router.common.js index 321448dcb..82af883df 100644 --- a/dist/vue-router.common.js +++ b/dist/vue-router.common.js @@ -1,5 +1,5 @@ /** - * vue-router v2.5.3 + * vue-router v2.6.0 * (c) 2017 Evan You * @license MIT */ @@ -47,7 +47,7 @@ var View = { // has been toggled inactive but kept-alive. var depth = 0; var inactive = false; - while (parent) { + while (parent && parent._routerRoot !== parent) { if (parent.$vnode && parent.$vnode.data.routerView) { depth++; } @@ -198,7 +198,7 @@ function stringifyQuery (obj) { if (Array.isArray(val)) { var result = []; - val.slice().forEach(function (val2) { + val.forEach(function (val2) { if (val2 === undefined) { return } @@ -302,7 +302,15 @@ function isObjectEqual (a, b) { if (aKeys.length !== bKeys.length) { return false } - return aKeys.every(function (key) { return String(a[key]) === String(b[key]); }) + return aKeys.every(function (key) { + var aVal = a[key]; + var bVal = b[key]; + // check nested equality + if (typeof aVal === 'object' && typeof bVal === 'object') { + return isObjectEqual(aVal, bVal) + } + return String(aVal) === String(bVal) + }) } function isIncludedRoute (current, target) { @@ -433,7 +441,7 @@ var Link = { function guardEvent (e) { // don't redirect with control keys - if (e.metaKey || e.ctrlKey || e.shiftKey) { return } + if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) { return } // don't redirect when preventDefault called if (e.defaultPrevented) { return } // don't redirect on right click @@ -473,14 +481,6 @@ function install (Vue) { _Vue = Vue; - Object.defineProperty(Vue.prototype, '$router', { - get: function get () { return this.$root._router } - }); - - Object.defineProperty(Vue.prototype, '$route', { - get: function get () { return this.$root._route } - }); - var isDef = function (v) { return v !== undefined; }; var registerInstance = function (vm, callVal) { @@ -493,9 +493,12 @@ function install (Vue) { Vue.mixin({ beforeCreate: function beforeCreate () { if (isDef(this.$options.router)) { + this._routerRoot = this; this._router = this.$options.router; this._router.init(this); Vue.util.defineReactive(this, '_route', this._router.history.current); + } else { + this._routerRoot = (this.$parent && this.$parent._routerRoot) || this; } registerInstance(this, this); }, @@ -504,6 +507,14 @@ function install (Vue) { } }); + Object.defineProperty(Vue.prototype, '$router', { + get: function get () { return this._routerRoot._router } + }); + + Object.defineProperty(Vue.prototype, '$route', { + get: function get () { return this._routerRoot._route } + }); + Vue.component('router-view', View); Vue.component('router-link', Link); @@ -1096,9 +1107,15 @@ function addRouteRecord ( } var normalizedPath = normalizePath(path, parent); + var pathToRegexpOptions = route.pathToRegexpOptions || {}; + + if (typeof route.caseSensitive === 'boolean') { + pathToRegexpOptions.sensitive = route.caseSensitive; + } + var record = { path: normalizedPath, - regex: compileRouteRegex(normalizedPath), + regex: compileRouteRegex(normalizedPath, pathToRegexpOptions), components: route.components || { default: route.component }, instances: {}, name: name, @@ -1115,11 +1132,11 @@ function addRouteRecord ( }; if (route.children) { - // Warn if route is named and has a default child route. + // Warn if route is named, does not redirect and has a default child route. // If users navigate to this route by name, the default child will // not be rendered (GH Issue #629) if (process.env.NODE_ENV !== 'production') { - if (route.name && route.children.some(function (child) { return /^\/?$/.test(child.path); })) { + if (route.name && !route.redirect && route.children.some(function (child) { return /^\/?$/.test(child.path); })) { warn( false, "Named Route '" + (route.name) + "' has a default child route. " + @@ -1139,21 +1156,24 @@ function addRouteRecord ( } if (route.alias !== undefined) { - if (Array.isArray(route.alias)) { - route.alias.forEach(function (alias) { - var aliasRoute = { - path: alias, - children: route.children - }; - addRouteRecord(pathList, pathMap, nameMap, aliasRoute, parent, record.path); - }); - } else { + var aliases = Array.isArray(route.alias) + ? route.alias + : [route.alias]; + + aliases.forEach(function (alias) { var aliasRoute = { - path: route.alias, + path: alias, children: route.children }; - addRouteRecord(pathList, pathMap, nameMap, aliasRoute, parent, record.path); - } + addRouteRecord( + pathList, + pathMap, + nameMap, + aliasRoute, + parent, + record.path || '/' // matchAs + ); + }); } if (!pathMap[record.path]) { @@ -1174,8 +1194,8 @@ function addRouteRecord ( } } -function compileRouteRegex (path) { - var regex = index(path); +function compileRouteRegex (path, pathToRegexpOptions) { + var regex = index(path, [], pathToRegexpOptions); if (process.env.NODE_ENV !== 'production') { var keys = {}; regex.keys.forEach(function (key) { @@ -1216,7 +1236,7 @@ function normalizeLocation ( if (current.name) { next.name = current.name; next.params = params; - } else if (current.matched) { + } else if (current.matched.length) { var rawPath = current.matched[current.matched.length - 1].path; next.path = fillParams(rawPath, params, ("path " + (current.path))); } else if (process.env.NODE_ENV !== 'production') { @@ -1286,6 +1306,7 @@ function createMatcher ( if (process.env.NODE_ENV !== 'production') { warn(record, ("Route with name '" + name + "' does not exist")); } + if (!record) { return _createRoute(null, location) } var paramNames = record.regex.keys .filter(function (key) { return !key.optional; }) .map(function (key) { return key.name; }); @@ -1496,7 +1517,9 @@ function handleScroll ( if (isObject && typeof shouldScroll.selector === 'string') { var el = document.querySelector(shouldScroll.selector); if (el) { - position = getElementPosition(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); } @@ -1527,13 +1550,13 @@ function getScrollPosition () { } } -function getElementPosition (el) { +function getElementPosition (el, offset) { var docEl = document.documentElement; var docRect = docEl.getBoundingClientRect(); var elRect = el.getBoundingClientRect(); return { - x: elRect.left - docRect.left, - y: elRect.top - docRect.top + x: elRect.left - docRect.left - offset.x, + y: elRect.top - docRect.top - offset.y } } @@ -1548,6 +1571,13 @@ function normalizePosition (obj) { } } +function normalizeOffset (obj) { + return { + x: isNumber(obj.x) ? obj.x : 0, + y: isNumber(obj.y) ? obj.y : 0 + } +} + function isNumber (v) { return typeof v === 'number' } @@ -1800,6 +1830,8 @@ function normalizeBase (base) { // respect tag var baseEl = document.querySelector('base'); base = (baseEl && baseEl.getAttribute('href')) || '/'; + // strip full URL origin + base = base.replace(/^https?:\/\/[^\/]+/, ''); } else { base = '/'; } @@ -2010,9 +2042,12 @@ function flatten (arr) { function once (fn) { var called = false; return function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + if (called) { return } called = true; - return fn.apply(this, arguments) + return fn.apply(this, args) } } @@ -2036,9 +2071,10 @@ var HTML5History = (function (History$$1) { } window.addEventListener('popstate', function (e) { + var current = this$1.current; this$1.transitionTo(getLocation(this$1.base), function (route) { if (expectScroll) { - handleScroll(router, route, this$1.current, true); + handleScroll(router, route, current, true); } }); }); @@ -2194,10 +2230,10 @@ function pushHash (path) { } function replaceHash (path) { - var i = window.location.href.indexOf('#'); - window.location.replace( - window.location.href.slice(0, i >= 0 ? i : 0) + '#' + path - ); + var href = window.location.href; + var i = href.indexOf('#'); + var base = i >= 0 ? href.slice(0, i) : href; + window.location.replace((base + "#" + path)); } /* */ @@ -2273,7 +2309,7 @@ var VueRouter = function VueRouter (options) { this.matcher = createMatcher(options.routes || [], this); var mode = options.mode || 'hash'; - this.fallback = mode === 'history' && !supportsPushState; + this.fallback = mode === 'history' && !supportsPushState && options.fallback !== false; if (this.fallback) { mode = 'hash'; } @@ -2457,7 +2493,7 @@ function createHref (base, fullPath, mode) { } VueRouter.install = install; -VueRouter.version = '2.5.3'; +VueRouter.version = '2.6.0'; if (inBrowser && window.Vue) { window.Vue.use(VueRouter); diff --git a/dist/vue-router.esm.js b/dist/vue-router.esm.js index f8ef33f15..a97f1d7bd 100644 --- a/dist/vue-router.esm.js +++ b/dist/vue-router.esm.js @@ -1,5 +1,5 @@ /** - * vue-router v2.5.3 + * vue-router v2.6.0 * (c) 2017 Evan You * @license MIT */ @@ -45,7 +45,7 @@ var View = { // has been toggled inactive but kept-alive. var depth = 0; var inactive = false; - while (parent) { + while (parent && parent._routerRoot !== parent) { if (parent.$vnode && parent.$vnode.data.routerView) { depth++; } @@ -196,7 +196,7 @@ function stringifyQuery (obj) { if (Array.isArray(val)) { var result = []; - val.slice().forEach(function (val2) { + val.forEach(function (val2) { if (val2 === undefined) { return } @@ -300,7 +300,15 @@ function isObjectEqual (a, b) { if (aKeys.length !== bKeys.length) { return false } - return aKeys.every(function (key) { return String(a[key]) === String(b[key]); }) + return aKeys.every(function (key) { + var aVal = a[key]; + var bVal = b[key]; + // check nested equality + if (typeof aVal === 'object' && typeof bVal === 'object') { + return isObjectEqual(aVal, bVal) + } + return String(aVal) === String(bVal) + }) } function isIncludedRoute (current, target) { @@ -431,7 +439,7 @@ var Link = { function guardEvent (e) { // don't redirect with control keys - if (e.metaKey || e.ctrlKey || e.shiftKey) { return } + if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) { return } // don't redirect when preventDefault called if (e.defaultPrevented) { return } // don't redirect on right click @@ -471,14 +479,6 @@ function install (Vue) { _Vue = Vue; - Object.defineProperty(Vue.prototype, '$router', { - get: function get () { return this.$root._router } - }); - - Object.defineProperty(Vue.prototype, '$route', { - get: function get () { return this.$root._route } - }); - var isDef = function (v) { return v !== undefined; }; var registerInstance = function (vm, callVal) { @@ -491,9 +491,12 @@ function install (Vue) { Vue.mixin({ beforeCreate: function beforeCreate () { if (isDef(this.$options.router)) { + this._routerRoot = this; this._router = this.$options.router; this._router.init(this); Vue.util.defineReactive(this, '_route', this._router.history.current); + } else { + this._routerRoot = (this.$parent && this.$parent._routerRoot) || this; } registerInstance(this, this); }, @@ -502,6 +505,14 @@ function install (Vue) { } }); + Object.defineProperty(Vue.prototype, '$router', { + get: function get () { return this._routerRoot._router } + }); + + Object.defineProperty(Vue.prototype, '$route', { + get: function get () { return this._routerRoot._route } + }); + Vue.component('router-view', View); Vue.component('router-link', Link); @@ -1094,9 +1105,15 @@ function addRouteRecord ( } var normalizedPath = normalizePath(path, parent); + var pathToRegexpOptions = route.pathToRegexpOptions || {}; + + if (typeof route.caseSensitive === 'boolean') { + pathToRegexpOptions.sensitive = route.caseSensitive; + } + var record = { path: normalizedPath, - regex: compileRouteRegex(normalizedPath), + regex: compileRouteRegex(normalizedPath, pathToRegexpOptions), components: route.components || { default: route.component }, instances: {}, name: name, @@ -1113,11 +1130,11 @@ function addRouteRecord ( }; if (route.children) { - // Warn if route is named and has a default child route. + // Warn if route is named, does not redirect and has a default child route. // If users navigate to this route by name, the default child will // not be rendered (GH Issue #629) if (process.env.NODE_ENV !== 'production') { - if (route.name && route.children.some(function (child) { return /^\/?$/.test(child.path); })) { + if (route.name && !route.redirect && route.children.some(function (child) { return /^\/?$/.test(child.path); })) { warn( false, "Named Route '" + (route.name) + "' has a default child route. " + @@ -1137,21 +1154,24 @@ function addRouteRecord ( } if (route.alias !== undefined) { - if (Array.isArray(route.alias)) { - route.alias.forEach(function (alias) { - var aliasRoute = { - path: alias, - children: route.children - }; - addRouteRecord(pathList, pathMap, nameMap, aliasRoute, parent, record.path); - }); - } else { + var aliases = Array.isArray(route.alias) + ? route.alias + : [route.alias]; + + aliases.forEach(function (alias) { var aliasRoute = { - path: route.alias, + path: alias, children: route.children }; - addRouteRecord(pathList, pathMap, nameMap, aliasRoute, parent, record.path); - } + addRouteRecord( + pathList, + pathMap, + nameMap, + aliasRoute, + parent, + record.path || '/' // matchAs + ); + }); } if (!pathMap[record.path]) { @@ -1172,8 +1192,8 @@ function addRouteRecord ( } } -function compileRouteRegex (path) { - var regex = index(path); +function compileRouteRegex (path, pathToRegexpOptions) { + var regex = index(path, [], pathToRegexpOptions); if (process.env.NODE_ENV !== 'production') { var keys = {}; regex.keys.forEach(function (key) { @@ -1214,7 +1234,7 @@ function normalizeLocation ( if (current.name) { next.name = current.name; next.params = params; - } else if (current.matched) { + } else if (current.matched.length) { var rawPath = current.matched[current.matched.length - 1].path; next.path = fillParams(rawPath, params, ("path " + (current.path))); } else if (process.env.NODE_ENV !== 'production') { @@ -1284,6 +1304,7 @@ function createMatcher ( if (process.env.NODE_ENV !== 'production') { warn(record, ("Route with name '" + name + "' does not exist")); } + if (!record) { return _createRoute(null, location) } var paramNames = record.regex.keys .filter(function (key) { return !key.optional; }) .map(function (key) { return key.name; }); @@ -1494,7 +1515,9 @@ function handleScroll ( if (isObject && typeof shouldScroll.selector === 'string') { var el = document.querySelector(shouldScroll.selector); if (el) { - position = getElementPosition(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); } @@ -1525,13 +1548,13 @@ function getScrollPosition () { } } -function getElementPosition (el) { +function getElementPosition (el, offset) { var docEl = document.documentElement; var docRect = docEl.getBoundingClientRect(); var elRect = el.getBoundingClientRect(); return { - x: elRect.left - docRect.left, - y: elRect.top - docRect.top + x: elRect.left - docRect.left - offset.x, + y: elRect.top - docRect.top - offset.y } } @@ -1546,6 +1569,13 @@ function normalizePosition (obj) { } } +function normalizeOffset (obj) { + return { + x: isNumber(obj.x) ? obj.x : 0, + y: isNumber(obj.y) ? obj.y : 0 + } +} + function isNumber (v) { return typeof v === 'number' } @@ -1798,6 +1828,8 @@ function normalizeBase (base) { // respect tag var baseEl = document.querySelector('base'); base = (baseEl && baseEl.getAttribute('href')) || '/'; + // strip full URL origin + base = base.replace(/^https?:\/\/[^\/]+/, ''); } else { base = '/'; } @@ -2008,9 +2040,12 @@ function flatten (arr) { function once (fn) { var called = false; return function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + if (called) { return } called = true; - return fn.apply(this, arguments) + return fn.apply(this, args) } } @@ -2034,9 +2069,10 @@ var HTML5History = (function (History$$1) { } window.addEventListener('popstate', function (e) { + var current = this$1.current; this$1.transitionTo(getLocation(this$1.base), function (route) { if (expectScroll) { - handleScroll(router, route, this$1.current, true); + handleScroll(router, route, current, true); } }); }); @@ -2192,10 +2228,10 @@ function pushHash (path) { } function replaceHash (path) { - var i = window.location.href.indexOf('#'); - window.location.replace( - window.location.href.slice(0, i >= 0 ? i : 0) + '#' + path - ); + var href = window.location.href; + var i = href.indexOf('#'); + var base = i >= 0 ? href.slice(0, i) : href; + window.location.replace((base + "#" + path)); } /* */ @@ -2271,7 +2307,7 @@ var VueRouter = function VueRouter (options) { this.matcher = createMatcher(options.routes || [], this); var mode = options.mode || 'hash'; - this.fallback = mode === 'history' && !supportsPushState; + this.fallback = mode === 'history' && !supportsPushState && options.fallback !== false; if (this.fallback) { mode = 'hash'; } @@ -2455,7 +2491,7 @@ function createHref (base, fullPath, mode) { } VueRouter.install = install; -VueRouter.version = '2.5.3'; +VueRouter.version = '2.6.0'; if (inBrowser && window.Vue) { window.Vue.use(VueRouter); diff --git a/dist/vue-router.js b/dist/vue-router.js index 0f1a1501b..a3a2dd73b 100644 --- a/dist/vue-router.js +++ b/dist/vue-router.js @@ -1,5 +1,5 @@ /** - * vue-router v2.5.3 + * vue-router v2.6.0 * (c) 2017 Evan You * @license MIT */ @@ -51,7 +51,7 @@ var View = { // has been toggled inactive but kept-alive. var depth = 0; var inactive = false; - while (parent) { + while (parent && parent._routerRoot !== parent) { if (parent.$vnode && parent.$vnode.data.routerView) { depth++; } @@ -202,7 +202,7 @@ function stringifyQuery (obj) { if (Array.isArray(val)) { var result = []; - val.slice().forEach(function (val2) { + val.forEach(function (val2) { if (val2 === undefined) { return } @@ -306,7 +306,15 @@ function isObjectEqual (a, b) { if (aKeys.length !== bKeys.length) { return false } - return aKeys.every(function (key) { return String(a[key]) === String(b[key]); }) + return aKeys.every(function (key) { + var aVal = a[key]; + var bVal = b[key]; + // check nested equality + if (typeof aVal === 'object' && typeof bVal === 'object') { + return isObjectEqual(aVal, bVal) + } + return String(aVal) === String(bVal) + }) } function isIncludedRoute (current, target) { @@ -437,7 +445,7 @@ var Link = { function guardEvent (e) { // don't redirect with control keys - if (e.metaKey || e.ctrlKey || e.shiftKey) { return } + if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) { return } // don't redirect when preventDefault called if (e.defaultPrevented) { return } // don't redirect on right click @@ -477,14 +485,6 @@ function install (Vue) { _Vue = Vue; - Object.defineProperty(Vue.prototype, '$router', { - get: function get () { return this.$root._router } - }); - - Object.defineProperty(Vue.prototype, '$route', { - get: function get () { return this.$root._route } - }); - var isDef = function (v) { return v !== undefined; }; var registerInstance = function (vm, callVal) { @@ -497,9 +497,12 @@ function install (Vue) { Vue.mixin({ beforeCreate: function beforeCreate () { if (isDef(this.$options.router)) { + this._routerRoot = this; this._router = this.$options.router; this._router.init(this); Vue.util.defineReactive(this, '_route', this._router.history.current); + } else { + this._routerRoot = (this.$parent && this.$parent._routerRoot) || this; } registerInstance(this, this); }, @@ -508,6 +511,14 @@ function install (Vue) { } }); + Object.defineProperty(Vue.prototype, '$router', { + get: function get () { return this._routerRoot._router } + }); + + Object.defineProperty(Vue.prototype, '$route', { + get: function get () { return this._routerRoot._route } + }); + Vue.component('router-view', View); Vue.component('router-link', Link); @@ -1100,9 +1111,15 @@ function addRouteRecord ( } var normalizedPath = normalizePath(path, parent); + var pathToRegexpOptions = route.pathToRegexpOptions || {}; + + if (typeof route.caseSensitive === 'boolean') { + pathToRegexpOptions.sensitive = route.caseSensitive; + } + var record = { path: normalizedPath, - regex: compileRouteRegex(normalizedPath), + regex: compileRouteRegex(normalizedPath, pathToRegexpOptions), components: route.components || { default: route.component }, instances: {}, name: name, @@ -1119,11 +1136,11 @@ function addRouteRecord ( }; if (route.children) { - // Warn if route is named and has a default child route. + // Warn if route is named, does not redirect and has a default child route. // If users navigate to this route by name, the default child will // not be rendered (GH Issue #629) { - if (route.name && route.children.some(function (child) { return /^\/?$/.test(child.path); })) { + if (route.name && !route.redirect && route.children.some(function (child) { return /^\/?$/.test(child.path); })) { warn( false, "Named Route '" + (route.name) + "' has a default child route. " + @@ -1143,21 +1160,24 @@ function addRouteRecord ( } if (route.alias !== undefined) { - if (Array.isArray(route.alias)) { - route.alias.forEach(function (alias) { - var aliasRoute = { - path: alias, - children: route.children - }; - addRouteRecord(pathList, pathMap, nameMap, aliasRoute, parent, record.path); - }); - } else { + var aliases = Array.isArray(route.alias) + ? route.alias + : [route.alias]; + + aliases.forEach(function (alias) { var aliasRoute = { - path: route.alias, + path: alias, children: route.children }; - addRouteRecord(pathList, pathMap, nameMap, aliasRoute, parent, record.path); - } + addRouteRecord( + pathList, + pathMap, + nameMap, + aliasRoute, + parent, + record.path || '/' // matchAs + ); + }); } if (!pathMap[record.path]) { @@ -1178,8 +1198,8 @@ function addRouteRecord ( } } -function compileRouteRegex (path) { - var regex = index(path); +function compileRouteRegex (path, pathToRegexpOptions) { + var regex = index(path, [], pathToRegexpOptions); { var keys = {}; regex.keys.forEach(function (key) { @@ -1220,7 +1240,7 @@ function normalizeLocation ( if (current.name) { next.name = current.name; next.params = params; - } else if (current.matched) { + } else if (current.matched.length) { var rawPath = current.matched[current.matched.length - 1].path; next.path = fillParams(rawPath, params, ("path " + (current.path))); } else { @@ -1290,6 +1310,7 @@ function createMatcher ( { warn(record, ("Route with name '" + name + "' does not exist")); } + if (!record) { return _createRoute(null, location) } var paramNames = record.regex.keys .filter(function (key) { return !key.optional; }) .map(function (key) { return key.name; }); @@ -1500,7 +1521,9 @@ function handleScroll ( if (isObject && typeof shouldScroll.selector === 'string') { var el = document.querySelector(shouldScroll.selector); if (el) { - position = getElementPosition(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); } @@ -1531,13 +1554,13 @@ function getScrollPosition () { } } -function getElementPosition (el) { +function getElementPosition (el, offset) { var docEl = document.documentElement; var docRect = docEl.getBoundingClientRect(); var elRect = el.getBoundingClientRect(); return { - x: elRect.left - docRect.left, - y: elRect.top - docRect.top + x: elRect.left - docRect.left - offset.x, + y: elRect.top - docRect.top - offset.y } } @@ -1552,6 +1575,13 @@ function normalizePosition (obj) { } } +function normalizeOffset (obj) { + return { + x: isNumber(obj.x) ? obj.x : 0, + y: isNumber(obj.y) ? obj.y : 0 + } +} + function isNumber (v) { return typeof v === 'number' } @@ -1804,6 +1834,8 @@ function normalizeBase (base) { // respect tag var baseEl = document.querySelector('base'); base = (baseEl && baseEl.getAttribute('href')) || '/'; + // strip full URL origin + base = base.replace(/^https?:\/\/[^\/]+/, ''); } else { base = '/'; } @@ -2014,9 +2046,12 @@ function flatten (arr) { function once (fn) { var called = false; return function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + if (called) { return } called = true; - return fn.apply(this, arguments) + return fn.apply(this, args) } } @@ -2040,9 +2075,10 @@ var HTML5History = (function (History$$1) { } window.addEventListener('popstate', function (e) { + var current = this$1.current; this$1.transitionTo(getLocation(this$1.base), function (route) { if (expectScroll) { - handleScroll(router, route, this$1.current, true); + handleScroll(router, route, current, true); } }); }); @@ -2198,10 +2234,10 @@ function pushHash (path) { } function replaceHash (path) { - var i = window.location.href.indexOf('#'); - window.location.replace( - window.location.href.slice(0, i >= 0 ? i : 0) + '#' + path - ); + var href = window.location.href; + var i = href.indexOf('#'); + var base = i >= 0 ? href.slice(0, i) : href; + window.location.replace((base + "#" + path)); } /* */ @@ -2277,7 +2313,7 @@ var VueRouter = function VueRouter (options) { this.matcher = createMatcher(options.routes || [], this); var mode = options.mode || 'hash'; - this.fallback = mode === 'history' && !supportsPushState; + this.fallback = mode === 'history' && !supportsPushState && options.fallback !== false; if (this.fallback) { mode = 'hash'; } @@ -2461,7 +2497,7 @@ function createHref (base, fullPath, mode) { } VueRouter.install = install; -VueRouter.version = '2.5.3'; +VueRouter.version = '2.6.0'; if (inBrowser && window.Vue) { window.Vue.use(VueRouter); diff --git a/dist/vue-router.min.js b/dist/vue-router.min.js index 27bf34aab..4c11bb885 100644 --- a/dist/vue-router.min.js +++ b/dist/vue-router.min.js @@ -1,6 +1,6 @@ /** - * vue-router v2.5.3 + * vue-router v2.6.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,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,n){void 0===e&&(e={});var o,i=n||r;try{o=i(t||"")}catch(t){o={}}for(var a in e){var u=e[a];o[a]=Array.isArray(u)?u.slice():u}return o}function r(t){var e={};return(t=t.trim().replace(/^(\?|#|&)/,""))?(t.split("&").forEach(function(t){var n=t.replace(/\+/g," ").split("="),r=$t(n.shift()),o=n.length>0?$t(n.join("=")):null;void 0===e[r]?e[r]=o:Array.isArray(e[r])?e[r].push(o):e[r]=[e[r],o]}),e):e}function o(t){var e=t?Object.keys(t).map(function(e){var n=t[e];if(void 0===n)return"";if(null===n)return _t(e);if(Array.isArray(n)){var r=[];return n.slice().forEach(function(t){void 0!==t&&(null===t?r.push(_t(e)):r.push(_t(e)+"="+_t(t)))}),r.join("&")}return _t(e)+"="+_t(n)}).filter(function(t){return t.length>0}).join("&"):null;return e?"?"+e:""}function i(t,e,n,r){var o=r&&r.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:u(e,o),matched:t?a(t):[]};return n&&(i.redirectedFrom=u(n,o)),Object.freeze(i)}function a(t){for(var e=[];t;)e.unshift(t),t=t.parent;return e}function u(t,e){var n=t.path,r=t.query;void 0===r&&(r={});var i=t.hash;void 0===i&&(i="");var a=e||o;return(n||"/")+a(r)+i}function c(t,e){return e===qt?t===e:!!e&&(t.path&&e.path?t.path.replace(St,"")===e.path.replace(St,"")&&t.hash===e.hash&&s(t.query,e.query):!(!t.name||!e.name)&&(t.name===e.name&&t.hash===e.hash&&s(t.query,e.query)&&s(t.params,e.params)))}function s(t,e){void 0===t&&(t={}),void 0===e&&(e={});var n=Object.keys(t),r=Object.keys(e);return n.length===r.length&&n.every(function(n){return String(t[n])===String(e[n])})}function p(t,e){return 0===t.path.replace(St,"/").indexOf(e.path.replace(St,"/"))&&(!e.hash||t.hash===e.hash)&&f(t.query,e.query)}function f(t,e){for(var n in e)if(!(n in t))return!1;return!0}function h(t){if(!(t.metaKey||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 l(t){if(t)for(var e,n=0;n=0&&(e=t.slice(r),t=t.slice(0,r));var o=t.indexOf("?");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{path:t,query:n,hash:e}}function m(t){return t.replace(/\/\//g,"/")}function g(t,e){for(var n,r=[],o=0,i=0,a="",u=e&&e.delimiter||"/";null!=(n=Dt.exec(t));){var c=n[0],s=n[1],p=n.index;if(a+=t.slice(i,p),i=p+c.length,s)a+=s[1];else{var f=t[i],h=n[2],l=n[3],d=n[4],y=n[5],v=n[6],m=n[7];a&&(r.push(a),a="");var g=null!=h&&null!=f&&f!==h,w="+"===v||"*"===v,b="?"===v||"*"===v,x=n[2]||u,k=d||y;r.push({name:l||o++,prefix:h||"",delimiter:x,optional:b,repeat:w,partial:g,asterisk:!!m,pattern:k?O(k):m?".*":"[^"+E(x)+"]+?"})}}return i-1&&(o.params[h]=n.params[h]);if(a)return o.path=S(a.path,o.params,'named route "'+i+'"'),u(a,o,r)}else if(o.path){o.params={};for(var l=0;l=t.length?n():t[o]?e(t[o],function(){r(o+1)}):r(o+1)};r(0)}function nt(t){if(!t)if(Ht){var e=document.querySelector("base");t=e&&e.getAttribute("href")||"/"}else t="/";return"/"!==t.charAt(0)&&(t="/"+t),t.replace(/\/$/,"")}function rt(t,e){var n,r=Math.max(t.length,e.length);for(n=0;n-1}function mt(t){var e=window.location.pathname;return t&&0===e.indexOf(t)&&(e=e.slice(t.length)),(e||"/")+window.location.search+window.location.hash}function gt(t){var e=mt(t);if(!/^\/#/.test(e))return window.location.replace(m(t+"/#"+e)),!0}function wt(){var t=bt();return"/"===t.charAt(0)||(kt("/"+t),!1)}function bt(){var t=window.location.href,e=t.indexOf("#");return e===-1?"":t.slice(e+1)}function xt(t){window.location.hash=t}function kt(t){var e=window.location.href.indexOf("#");window.location.replace(window.location.href.slice(0,e>=0?e:0)+"#"+t)}function Et(t,e){return t.push(e),function(){var n=t.indexOf(e);n>-1&&t.splice(n,1)}}function Ot(t,e,n){var r="hash"===n?"#"+e:e;return t?m(t+"/"+r):r}var Rt,Ct={name:"router-view",functional:!0,props:{name:{type:String,default:"default"}},render:function(t,n){var r=n.props,o=n.children,i=n.parent,a=n.data;a.routerView=!0;for(var u=i.$createElement,c=r.name,s=i.$route,p=i._routerViewCache||(i._routerViewCache={}),f=0,h=!1;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 n=l.instances[c];(e&&n!==t||!e&&n===t)&&(l.instances[c]=e)},(a.hook||(a.hook={})).prepatch=function(t,e){l.instances[c]=e.componentInstance},a.props=e(s,l.props&&l.props[c]),u(d,a,o)}},At=/[!'()*]/g,jt=function(t){return"%"+t.charCodeAt(0).toString(16)},Tt=/%2C/g,_t=function(t){return encodeURIComponent(t).replace(At,jt).replace(Tt,",")},$t=decodeURIComponent,St=/\/?$/,qt=i(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,n=this.$router,r=this.$route,o=n.resolve(this.to,r,this.append),a=o.location,u=o.route,s=o.href,f={},d=n.options.linkActiveClass,y=n.options.linkExactActiveClass,v=null==d?"router-link-active":d,m=null==y?"router-link-exact-active":y,g=null==this.activeClass?v:this.activeClass,w=null==this.exactActiveClass?m:this.exactActiveClass,b=a.path?i(null,a,null,n):u;f[w]=c(r,b),f[g]=this.exact?f[w]:p(r,b);var x=function(t){h(t)&&(e.replace?n.replace(a):n.push(a))},k={click:h};Array.isArray(this.event)?this.event.forEach(function(t){k[t]=x}):k[this.event]=x;var E={class:f};if("a"===this.tag)E.on=k,E.attrs={href:s};else{var O=l(this.$slots.default);if(O){O.isStatic=!1;var R=Rt.util.extend,C=O.data=R({},O.data);C.on=k;var A=O.data.attrs=R({},O.data.attrs);A.href=s}else E.on=k}return t(this.tag,E,this.$slots.default)}},Ht="undefined"!=typeof window,It=Array.isArray||function(t){return"[object Array]"==Object.prototype.toString.call(t)},Vt=$,zt=g,Mt=w,Bt=k,Ft=_,Dt=new RegExp(["(\\\\.)","([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))"].join("|"),"g");Vt.parse=zt,Vt.compile=Mt,Vt.tokensToFunction=Bt,Vt.tokensToRegExp=Ft;var Kt=Object.create(null),Jt=Object.create(null),Nt=Ht&&function(){var t=window.navigator.userAgent;return(t.indexOf("Android 2.")===-1&&t.indexOf("Android 4.0")===-1||t.indexOf("Mobile Safari")===-1||t.indexOf("Chrome")!==-1||t.indexOf("Windows Phone")!==-1)&&(window.history&&"pushState"in window.history)}(),Qt=Ht&&window.performance&&window.performance.now?window.performance:Date,Xt=Y(),Yt=function(t,e){this.router=t,this.base=nt(e),this.current=qt,this.pending=null,this.ready=!1,this.readyCbs=[],this.readyErrorCbs=[],this.errorCbs=[]};Yt.prototype.listen=function(t){this.cb=t},Yt.prototype.onReady=function(t,e){this.ready?t():(this.readyCbs.push(t),e&&this.readyErrorCbs.push(e))},Yt.prototype.onError=function(t){this.errorCbs.push(t)},Yt.prototype.transitionTo=function(t,e,n){var r=this,o=this.router.match(t,this.current);this.confirmTransition(o,function(){r.updateRoute(o),e&&e(o),r.ensureURL(),r.ready||(r.ready=!0,r.readyCbs.forEach(function(t){t(o)}))},function(t){n&&n(t),t&&!r.ready&&(r.ready=!0,r.readyErrorCbs.forEach(function(e){e(t)}))})},Yt.prototype.confirmTransition=function(e,n,r){var o=this,i=this.current,a=function(e){vt(e)&&(o.errorCbs.length?o.errorCbs.forEach(function(t){t(e)}):(t(!1,"uncaught error during route navigation:"),console.error(e))),r&&r(e)};if(c(e,i)&&e.matched.length===i.matched.length)return this.ensureURL(),a();var u=rt(this.current.matched,e.matched),s=u.updated,p=u.deactivated,f=u.activated,h=[].concat(at(p),this.router.beforeHooks,ut(s),f.map(function(t){return t.beforeEnter}),ht(f));this.pending=e;var l=function(t,n){if(o.pending!==e)return a();try{t(e,i,function(t){t===!1||vt(t)?(o.ensureURL(!0),a(t)):"string"==typeof t||"object"==typeof t&&("string"==typeof t.path||"string"==typeof t.name)?(a(),"object"==typeof t&&t.replace?o.replace(t):o.push(t)):n(t)})}catch(t){a(t)}};et(h,l,function(){var t=[],r=function(){return o.current===e},i=st(f,t,r),u=i.concat(o.router.resolveHooks);et(u,l,function(){return o.pending!==e?a():(o.pending=null,n(e),void(o.router.app&&o.router.app.$nextTick(function(){t.forEach(function(t){t()})})))})})},Yt.prototype.updateRoute=function(t){var e=this.current;this.current=t,this.cb&&this.cb(t),this.router.afterHooks.forEach(function(n){n&&n(t,e)})};var Wt=function(t){function e(e,n){var r=this;t.call(this,e,n);var o=e.options.scrollBehavior;o&&B(),window.addEventListener("popstate",function(t){r.transitionTo(mt(r.base),function(t){o&&F(e,t,r.current,!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,n){var r=this,o=this,i=o.current;this.transitionTo(t,function(t){Z(m(r.base+t.fullPath)),F(r.router,t,i,!1),e&&e(t)},n)},e.prototype.replace=function(t,e,n){var r=this,o=this,i=o.current;this.transitionTo(t,function(t){tt(m(r.base+t.fullPath)),F(r.router,t,i,!1),e&&e(t)},n)},e.prototype.ensureURL=function(t){if(mt(this.base)!==this.current.fullPath){var e=m(this.base+this.current.fullPath);t?Z(e):tt(e)}},e.prototype.getCurrentLocation=function(){return mt(this.base)},e}(Yt),Gt=function(t){function e(e,n,r){t.call(this,e,n),r&>(this.base)||wt()}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(){wt()&&t.transitionTo(bt(),function(t){kt(t.fullPath)})})},e.prototype.push=function(t,e,n){this.transitionTo(t,function(t){xt(t.fullPath),e&&e(t)},n)},e.prototype.replace=function(t,e,n){this.transitionTo(t,function(t){kt(t.fullPath),e&&e(t)},n)},e.prototype.go=function(t){window.history.go(t)},e.prototype.ensureURL=function(t){var e=this.current.fullPath;bt()!==e&&(t?xt(e):kt(e))},e.prototype.getCurrentLocation=function(){return bt()},e}(Yt),Zt=function(t){function e(e,n){t.call(this,e,n),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,n){var r=this;this.transitionTo(t,function(t){r.stack=r.stack.slice(0,r.index+1).concat(t),r.index++,e&&e(t)},n)},e.prototype.replace=function(t,e,n){var r=this;this.transitionTo(t,function(t){r.stack=r.stack.slice(0,r.index).concat(t),e&&e(t)},n)},e.prototype.go=function(t){var e=this,n=this.index+t;if(!(n<0||n>=this.stack.length)){var r=this.stack[n];this.confirmTransition(r,function(){e.index=n,e.updateRoute(r)})}},e.prototype.getCurrentLocation=function(){var t=this.stack[this.stack.length-1];return t?t.fullPath:"/"},e.prototype.ensureURL=function(){},e}(Yt),te=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&&!Nt,this.fallback&&(e="hash"),Ht||(e="abstract"),this.mode=e,e){case"history":this.history=new Wt(this,t.base);break;case"hash":this.history=new Gt(this,t.base,this.fallback);break;case"abstract":this.history=new Zt(this,t.base)}},ee={currentRoute:{}};return te.prototype.match=function(t,e,n){return this.matcher.match(t,e,n)},ee.currentRoute.get=function(){return this.history&&this.history.current},te.prototype.init=function(t){var e=this;if(this.apps.push(t),!this.app){this.app=t;var n=this.history;if(n instanceof Wt)n.transitionTo(n.getCurrentLocation());else if(n instanceof Gt){var r=function(){n.setupListeners()};n.transitionTo(n.getCurrentLocation(),r,r)}n.listen(function(t){e.apps.forEach(function(e){e._route=t})})}},te.prototype.beforeEach=function(t){return Et(this.beforeHooks,t)},te.prototype.beforeResolve=function(t){return Et(this.resolveHooks,t)},te.prototype.afterEach=function(t){return Et(this.afterHooks,t)},te.prototype.onReady=function(t,e){this.history.onReady(t,e)},te.prototype.onError=function(t){this.history.onError(t)},te.prototype.push=function(t,e,n){this.history.push(t,e,n)},te.prototype.replace=function(t,e,n){this.history.replace(t,e,n)},te.prototype.go=function(t){this.history.go(t)},te.prototype.back=function(){this.go(-1)},te.prototype.forward=function(){this.go(1)},te.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]})})):[]},te.prototype.resolve=function(t,e,n){var r=H(t,e||this.history.current,n,this),o=this.match(r,e),i=o.redirectedFrom||o.fullPath,a=this.history.base,u=Ot(a,i,this.mode);return{location:r,route:o,href:u,normalizedTo:r,resolved:o}},te.prototype.addRoutes=function(t){this.matcher.addRoutes(t),this.history.current!==qt&&this.history.transitionTo(this.history.getCurrentLocation())},Object.defineProperties(te.prototype,ee),te.install=d,te.version="2.5.3",Ht&&window.Vue&&window.Vue.use(te),te}); \ 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,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 r(t,e,r){void 0===e&&(e={});var o,i=r||n;try{o=i(t||"")}catch(t){o={}}for(var a in e){var u=e[a];o[a]=Array.isArray(u)?u.slice():u}return o}function n(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 o(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 i(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:u(e,o),matched:t?a(t):[]};return r&&(i.redirectedFrom=u(r,o)),Object.freeze(i)}function a(t){for(var e=[];t;)e.unshift(t),t=t.parent;return e}function u(t,e){var r=t.path,n=t.query;void 0===n&&(n={});var i=t.hash;void 0===i&&(i="");var a=e||o;return(r||"/")+a(n)+i}function c(t,e){return e===qt?t===e:!!e&&(t.path&&e.path?t.path.replace(St,"")===e.path.replace(St,"")&&t.hash===e.hash&&s(t.query,e.query):!(!t.name||!e.name)&&(t.name===e.name&&t.hash===e.hash&&s(t.query,e.query)&&s(t.params,e.params)))}function s(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?s(n,o):String(n)===String(o)})}function p(t,e){return 0===t.path.replace(St,"/").indexOf(e.path.replace(St,"/"))&&(!e.hash||t.hash===e.hash)&&f(t.query,e.query)}function f(t,e){for(var r in e)if(!(r in t))return!1;return!0}function h(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 l(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 m(t){return t.replace(/\/\//g,"/")}function g(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,R=d||y;n.push({name:l||o++,prefix:h||"",delimiter:x,optional:w,repeat:b,partial:g,asterisk:!!m,pattern:R?E(R):m?".*":"[^"+k(x)+"]+?"})}}return i-1&&(o.params[h]=r.params[h]);if(u)return o.path=$(u.path,o.params,'named route "'+i+'"'),a(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 rt(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 nt(t,e){var r,n=Math.max(t.length,e.length);for(r=0;r-1}function mt(t){var e=window.location.pathname;return t&&0===e.indexOf(t)&&(e=e.slice(t.length)),(e||"/")+window.location.search+window.location.hash}function gt(t){var e=mt(t);if(!/^\/#/.test(e))return window.location.replace(m(t+"/#"+e)),!0}function bt(){var t=wt();return"/"===t.charAt(0)||(kt("/"+t),!1)}function wt(){var t=window.location.href,e=t.indexOf("#");return-1===e?"":t.slice(e+1)}function xt(t){window.location.hash=t}function kt(t){var e=window.location.href,r=e.indexOf("#"),n=r>=0?e.slice(0,r):e;window.location.replace(n+"#"+t)}function Et(t,e){return t.push(e),function(){var r=t.indexOf(e);r>-1&&t.splice(r,1)}}function Rt(t,e,r){var n="hash"===r?"#"+e:e;return t?m(t+"/"+n):n}var Ot,Ct={name:"router-view",functional:!0,props:{name:{type:String,default:"default"}},render:function(t,r){var n=r.props,o=r.children,i=r.parent,a=r.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=e(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=i(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),a=o.location,u=o.route,s=o.href,f={},d=r.options.linkActiveClass,y=r.options.linkExactActiveClass,v=null==d?"router-link-active":d,m=null==y?"router-link-exact-active":y,g=null==this.activeClass?v:this.activeClass,b=null==this.exactActiveClass?m:this.exactActiveClass,w=a.path?i(null,a,null,r):u;f[b]=c(n,w),f[g]=this.exact?f[b]:p(n,w);var x=function(t){h(t)&&(e.replace?r.replace(a):r.push(a))},k={click:h};Array.isArray(this.event)?this.event.forEach(function(t){k[t]=x}):k[this.event]=x;var E={class:f};if("a"===this.tag)E.on=k,E.attrs={href:s};else{var R=l(this.$slots.default);if(R){R.isStatic=!1;var O=Ot.util.extend;(R.data=O({},R.data)).on=k,(R.data.attrs=O({},R.data.attrs)).href=s}else E.on=k}return t(this.tag,E,this.$slots.default)}},Ht="undefined"!=typeof window,It=Array.isArray||function(t){return"[object Array]"==Object.prototype.toString.call(t)},Vt=T,zt=g,Mt=x,Bt=_,Ft=new RegExp(["(\\\\.)","([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))"].join("|"),"g");Vt.parse=zt,Vt.compile=function(t,e){return x(g(t,e))},Vt.tokensToFunction=Mt,Vt.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=Y(),Xt=function(t,e){this.router=t,this.base=rt(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(e,r,n){var o=this,i=this.current,a=function(e){vt(e)&&(o.errorCbs.length?o.errorCbs.forEach(function(t){t(e)}):(t(!1,"uncaught error during route navigation:"),console.error(e))),n&&n(e)};if(c(e,i)&&e.matched.length===i.matched.length)return this.ensureURL(),a();var u=nt(this.current.matched,e.matched),s=u.updated,p=u.deactivated,f=u.activated,h=[].concat(at(p),this.router.beforeHooks,ut(s),f.map(function(t){return t.beforeEnter}),ht(f));this.pending=e;var l=function(t,r){if(o.pending!==e)return a();try{t(e,i,function(t){!1===t||vt(t)?(o.ensureURL(!0),a(t)):"string"==typeof t||"object"==typeof t&&("string"==typeof t.path||"string"==typeof t.name)?(a(),"object"==typeof t&&t.replace?o.replace(t):o.push(t)):r(t)})}catch(t){a(t)}};et(h,l,function(){var t=[];et(st(f,t,function(){return o.current===e}).concat(o.router.resolveHooks),l,function(){if(o.pending!==e)return a();o.pending=null,r(e),o.router.app&&o.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&&M(),window.addEventListener("popstate",function(t){var r=n.current;n.transitionTo(mt(n.base),function(t){o&&B(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){Z(m(n.base+t.fullPath)),B(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){tt(m(n.base+t.fullPath)),B(n.router,t,o,!1),e&&e(t)},r)},e.prototype.ensureURL=function(t){if(mt(this.base)!==this.current.fullPath){var e=m(this.base+this.current.fullPath);t?Z(e):tt(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=I(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 Et(this.beforeHooks,t)},Zt.prototype.beforeResolve=function(t){return Et(this.resolveHooks,t)},Zt.prototype.afterEach=function(t){return Et(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=U(t,e||this.history.current,r,this),o=this.match(n,e),i=o.redirectedFrom||o.fullPath;return{location:n,route:o,href:Rt(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=d,Zt.version="2.6.0",Ht&&window.Vue&&window.Vue.use(Zt),Zt}); \ No newline at end of file