Commit 8960c7ba authored by Adam Procter's avatar Adam Procter

update router

parent 167a8d12
Pipeline #161 failed with stages
in 1 minute and 21 seconds
......@@ -1316,7 +1316,7 @@
"vue-eslint-parser@^2.0.3": "https://registry.yarnpkg.com/vue-eslint-parser/-/vue-eslint-parser-2.0.3.tgz#c268c96c6d94cfe3d938a5f7593959b0ca3360d1",
"vue-hot-reload-api@^2.3.0": "https://registry.yarnpkg.com/vue-hot-reload-api/-/vue-hot-reload-api-2.3.1.tgz#b2d3d95402a811602380783ea4f566eb875569a2",
"vue-loader@^15.4.2": "https://registry.yarnpkg.com/vue-loader/-/vue-loader-15.4.2.tgz#812bb26e447dd3b84c485eb634190d914ce125e2",
"vue-router@^3.0.1": "https://registry.yarnpkg.com/vue-router/-/vue-router-3.0.1.tgz#d9b05ad9c7420ba0f626d6500d693e60092cc1e9",
"vue-router@^3.0.1": "https://registry.yarnpkg.com/vue-router/-/vue-router-3.0.2.tgz#dedc67afe6c4e2bc25682c8b1c2a8c0d7c7e56be",
"vue-style-loader@^4.1.0": "https://registry.yarnpkg.com/vue-style-loader/-/vue-style-loader-4.1.2.tgz#dedf349806f25ceb4e64f3ad7c0a44fba735fcf8",
"vue-template-compiler@^2.5.17": "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.5.17.tgz#52a4a078c327deb937482a509ae85c06f346c3cb",
"vue-template-es2015-compiler@^1.6.0": "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.6.0.tgz#dc42697133302ce3017524356a6c61b7b69b4a18",
......
MIT License
Copyright (c) 2013-2016 Evan You
Copyright (c) 2013-present Evan You
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......
# vue-router [![Build Status](https://img.shields.io/circleci/project/vuejs/vue-router/dev.svg)](https://circleci.com/gh/vuejs/vue-router)
# vue-router [![Build Status](https://img.shields.io/circleci/project/github/vuejs/vue-router/dev.svg)](https://circleci.com/gh/vuejs/vue-router)
> This is vue-router 2.0 which works only with Vue 2.0. For the 1.x router see the [1.0 branch](https://github.com/vuejs/vue-router/tree/1.0).
......@@ -32,7 +32,7 @@ npm run dev
# lint & run all tests
npm test
# serve docs at localhost:4000 (requires global gitbook-cli)
# serve docs at localhost:8080
npm run docs
```
......@@ -60,6 +60,6 @@ Details changes for each release are documented in the [release notes](https://g
[MIT](http://opensource.org/licenses/MIT)
Copyright (c) 2013-2017 Evan You
Copyright (c) 2013-present Evan You
/**
* vue-router v3.0.1
* (c) 2017 Evan You
/*!
* vue-router v3.0.2
* (c) 2018 Evan You
* @license MIT
*/
'use strict';
......@@ -23,8 +23,15 @@ function isError (err) {
return Object.prototype.toString.call(err).indexOf('Error') > -1
}
function extend (a, b) {
for (var key in b) {
a[key] = b[key];
}
return a
}
var View = {
name: 'router-view',
name: 'RouterView',
functional: true,
props: {
name: {
......@@ -38,6 +45,7 @@ var View = {
var parent = ref.parent;
var data = ref.data;
// used by devtools to display a router-view badge
data.routerView = true;
// directly use parent context's createElement() function
......@@ -112,7 +120,7 @@ var View = {
return h(component, data, children)
}
};
}
function resolveProps (route, config) {
switch (typeof config) {
......@@ -135,13 +143,6 @@ function resolveProps (route, config) {
}
}
function extend (to, from) {
for (var key in from) {
to[key] = from[key];
}
return to
}
/* */
var encodeReserveRE = /[!'()*]/g;
......@@ -240,7 +241,6 @@ function stringifyQuery (obj) {
/* */
var trailingSlashRE = /\/?$/;
function createRoute (
......@@ -383,7 +383,7 @@ var toTypes = [String, Object];
var eventTypes = [String, Array];
var Link = {
name: 'router-link',
name: 'RouterLink',
props: {
to: {
type: toTypes,
......@@ -418,17 +418,17 @@ var Link = {
var globalExactActiveClass = router.options.linkExactActiveClass;
// Support global empty active class
var activeClassFallback = globalActiveClass == null
? 'router-link-active'
: globalActiveClass;
? 'router-link-active'
: globalActiveClass;
var exactActiveClassFallback = globalExactActiveClass == null
? 'router-link-exact-active'
: globalExactActiveClass;
? 'router-link-exact-active'
: globalExactActiveClass;
var activeClass = this.activeClass == null
? activeClassFallback
: this.activeClass;
? activeClassFallback
: this.activeClass;
var exactActiveClass = this.exactActiveClass == null
? exactActiveClassFallback
: this.exactActiveClass;
? exactActiveClassFallback
: this.exactActiveClass;
var compareTarget = location.path
? createRoute(null, location, null, router)
: route;
......@@ -468,7 +468,6 @@ var Link = {
if (a) {
// in case the <a> is a static node
a.isStatic = false;
var extend = _Vue.util.extend;
var aData = a.data = extend({}, a.data);
aData.on = on;
var aAttrs = a.data.attrs = extend({}, a.data.attrs);
......@@ -481,7 +480,7 @@ var Link = {
return h(this.tag, data, this.$slots.default)
}
};
}
function guardEvent (e) {
// don't redirect with control keys
......@@ -559,8 +558,8 @@ function install (Vue) {
get: function get () { return this._routerRoot._route }
});
Vue.component('router-view', View);
Vue.component('router-link', Link);
Vue.component('RouterView', View);
Vue.component('RouterLink', Link);
var strats = Vue.config.optionMergeStrategies;
// use the same hook merging strategy for route hooks
......@@ -1070,7 +1069,6 @@ function pathToRegexp (path, keys, options) {
return stringToRegexp(/** @type {string} */ (path), /** @type {!Array} */ (keys), options)
}
pathToRegexp_1.parse = parse_1;
pathToRegexp_1.compile = compile_1;
pathToRegexp_1.tokensToFunction = tokensToFunction_1;
......@@ -1266,7 +1264,6 @@ function normalizePath (path, parent, strict) {
/* */
function normalizeLocation (
raw,
current,
......@@ -1281,9 +1278,9 @@ function normalizeLocation (
// relative params
if (!next.path && next.params && current) {
next = assign({}, next);
next = extend({}, next);
next._normalized = true;
var params = assign(assign({}, current.params), next.params);
var params = extend(extend({}, current.params), next.params);
if (current.name) {
next.name = current.name;
next.params = params;
......@@ -1321,16 +1318,10 @@ function normalizeLocation (
}
}
function assign (a, b) {
for (var key in b) {
a[key] = b[key];
}
return a
}
/* */
function createMatcher (
routes,
router
......@@ -1398,8 +1389,8 @@ function createMatcher (
) {
var originalRedirect = record.redirect;
var redirect = typeof originalRedirect === 'function'
? originalRedirect(createRoute(record, location, null, router))
: originalRedirect;
? originalRedirect(createRoute(record, location, null, router))
: originalRedirect;
if (typeof redirect === 'string') {
redirect = { path: redirect };
......@@ -1513,7 +1504,8 @@ function matchRoute (
var key = regex.keys[i - 1];
var val = typeof m[i] === 'string' ? decodeURIComponent(m[i]) : m[i];
if (key) {
params[key.name] = val;
// Fix #1994: using * with props: true generates a param named 0
params[key.name || 'pathMatch'] = val;
}
}
......@@ -1526,12 +1518,12 @@ function resolveRecordPath (path, record) {
/* */
var positionStore = Object.create(null);
function setupScroll () {
// Fix for #1585 for Firefox
window.history.replaceState({ key: getStateKey() }, '');
// Fix for #2195 Add optional third attribute to workaround a bug in safari https://bugs.webkit.org/show_bug.cgi?id=182678
window.history.replaceState({ key: getStateKey() }, '', window.location.href.replace(window.location.origin, ''));
window.addEventListener('popstate', function (e) {
saveScrollPosition();
if (e.state && e.state.key) {
......@@ -1562,7 +1554,7 @@ function handleScroll (
// wait until re-render finishes before scrolling
router.app.$nextTick(function () {
var position = getScrollPosition();
var shouldScroll = behavior(to, from, isPop ? position : null);
var shouldScroll = behavior.call(router, to, from, isPop ? position : null);
if (!shouldScroll) {
return
......@@ -2124,7 +2116,10 @@ function poll (
key,
isValid
) {
if (instances[key]) {
if (
instances[key] &&
!instances[key]._isBeingDestroyed // do not reuse being destroyed instance
) {
cb(instances[key]);
} else if (isValid()) {
setTimeout(function () {
......@@ -2135,7 +2130,6 @@ function poll (
/* */
var HTML5History = (function (History$$1) {
function HTML5History (router, base) {
var this$1 = this;
......@@ -2143,8 +2137,9 @@ var HTML5History = (function (History$$1) {
History$$1.call(this, router, base);
var expectScroll = router.options.scrollBehavior;
var supportsScroll = supportsPushState && expectScroll;
if (expectScroll) {
if (supportsScroll) {
setupScroll();
}
......@@ -2160,7 +2155,7 @@ var HTML5History = (function (History$$1) {
}
this$1.transitionTo(location, function (route) {
if (expectScroll) {
if (supportsScroll) {
handleScroll(router, route, current, true);
}
});
......@@ -2214,7 +2209,7 @@ var HTML5History = (function (History$$1) {
}(History));
function getLocation (base) {
var path = window.location.pathname;
var path = decodeURI(window.location.pathname);
if (base && path.indexOf(base) === 0) {
path = path.slice(base.length);
}
......@@ -2223,7 +2218,6 @@ function getLocation (base) {
/* */
var HashHistory = (function (History$$1) {
function HashHistory (router, base, fallback) {
History$$1.call(this, router, base);
......@@ -2333,7 +2327,7 @@ function getHash () {
// consistent across browsers - Firefox will pre-decode it!
var href = window.location.href;
var index = href.indexOf('#');
return index === -1 ? '' : href.slice(index + 1)
return index === -1 ? '' : decodeURI(href.slice(index + 1))
}
function getUrl (path) {
......@@ -2361,7 +2355,6 @@ function replaceHash (path) {
/* */
var AbstractHistory = (function (History$$1) {
function AbstractHistory (router, base) {
History$$1.call(this, router, base);
......@@ -2420,6 +2413,8 @@ var AbstractHistory = (function (History$$1) {
/* */
var VueRouter = function VueRouter (options) {
if ( options === void 0 ) options = {};
......@@ -2616,7 +2611,7 @@ function createHref (base, fullPath, mode) {
}
VueRouter.install = install;
VueRouter.version = '3.0.1';
VueRouter.version = '3.0.2';
if (inBrowser && window.Vue) {
window.Vue.use(VueRouter);
......
/**
* vue-router v3.0.1
* (c) 2017 Evan You
/*!
* vue-router v3.0.2
* (c) 2018 Evan You
* @license MIT
*/
/* */
......@@ -21,8 +21,15 @@ function isError (err) {
return Object.prototype.toString.call(err).indexOf('Error') > -1
}
function extend (a, b) {
for (var key in b) {
a[key] = b[key];
}
return a
}
var View = {
name: 'router-view',
name: 'RouterView',
functional: true,
props: {
name: {
......@@ -36,6 +43,7 @@ var View = {
var parent = ref.parent;
var data = ref.data;
// used by devtools to display a router-view badge
data.routerView = true;
// directly use parent context's createElement() function
......@@ -110,7 +118,7 @@ var View = {
return h(component, data, children)
}
};
}
function resolveProps (route, config) {
switch (typeof config) {
......@@ -133,13 +141,6 @@ function resolveProps (route, config) {
}
}
function extend (to, from) {
for (var key in from) {
to[key] = from[key];
}
return to
}
/* */
var encodeReserveRE = /[!'()*]/g;
......@@ -238,7 +239,6 @@ function stringifyQuery (obj) {
/* */
var trailingSlashRE = /\/?$/;
function createRoute (
......@@ -381,7 +381,7 @@ var toTypes = [String, Object];
var eventTypes = [String, Array];
var Link = {
name: 'router-link',
name: 'RouterLink',
props: {
to: {
type: toTypes,
......@@ -416,17 +416,17 @@ var Link = {
var globalExactActiveClass = router.options.linkExactActiveClass;
// Support global empty active class
var activeClassFallback = globalActiveClass == null
? 'router-link-active'
: globalActiveClass;
? 'router-link-active'
: globalActiveClass;
var exactActiveClassFallback = globalExactActiveClass == null
? 'router-link-exact-active'
: globalExactActiveClass;
? 'router-link-exact-active'
: globalExactActiveClass;
var activeClass = this.activeClass == null
? activeClassFallback
: this.activeClass;
? activeClassFallback
: this.activeClass;
var exactActiveClass = this.exactActiveClass == null
? exactActiveClassFallback
: this.exactActiveClass;
? exactActiveClassFallback
: this.exactActiveClass;
var compareTarget = location.path
? createRoute(null, location, null, router)
: route;
......@@ -466,7 +466,6 @@ var Link = {
if (a) {
// in case the <a> is a static node
a.isStatic = false;
var extend = _Vue.util.extend;
var aData = a.data = extend({}, a.data);
aData.on = on;
var aAttrs = a.data.attrs = extend({}, a.data.attrs);
......@@ -479,7 +478,7 @@ var Link = {
return h(this.tag, data, this.$slots.default)
}
};
}
function guardEvent (e) {
// don't redirect with control keys
......@@ -557,8 +556,8 @@ function install (Vue) {
get: function get () { return this._routerRoot._route }
});
Vue.component('router-view', View);
Vue.component('router-link', Link);
Vue.component('RouterView', View);
Vue.component('RouterLink', Link);
var strats = Vue.config.optionMergeStrategies;
// use the same hook merging strategy for route hooks
......@@ -1068,7 +1067,6 @@ function pathToRegexp (path, keys, options) {
return stringToRegexp(/** @type {string} */ (path), /** @type {!Array} */ (keys), options)
}
pathToRegexp_1.parse = parse_1;
pathToRegexp_1.compile = compile_1;
pathToRegexp_1.tokensToFunction = tokensToFunction_1;
......@@ -1264,7 +1262,6 @@ function normalizePath (path, parent, strict) {
/* */
function normalizeLocation (
raw,
current,
......@@ -1279,9 +1276,9 @@ function normalizeLocation (
// relative params
if (!next.path && next.params && current) {
next = assign({}, next);
next = extend({}, next);
next._normalized = true;
var params = assign(assign({}, current.params), next.params);
var params = extend(extend({}, current.params), next.params);
if (current.name) {
next.name = current.name;
next.params = params;
......@@ -1319,16 +1316,10 @@ function normalizeLocation (
}
}
function assign (a, b) {
for (var key in b) {
a[key] = b[key];
}
return a
}
/* */
function createMatcher (
routes,
router
......@@ -1396,8 +1387,8 @@ function createMatcher (
) {
var originalRedirect = record.redirect;
var redirect = typeof originalRedirect === 'function'
? originalRedirect(createRoute(record, location, null, router))
: originalRedirect;
? originalRedirect(createRoute(record, location, null, router))
: originalRedirect;
if (typeof redirect === 'string') {
redirect = { path: redirect };
......@@ -1511,7 +1502,8 @@ function matchRoute (
var key = regex.keys[i - 1];
var val = typeof m[i] === 'string' ? decodeURIComponent(m[i]) : m[i];
if (key) {
params[key.name] = val;
// Fix #1994: using * with props: true generates a param named 0
params[key.name || 'pathMatch'] = val;
}
}
......@@ -1524,12 +1516,12 @@ function resolveRecordPath (path, record) {
/* */
var positionStore = Object.create(null);
function setupScroll () {
// Fix for #1585 for Firefox
window.history.replaceState({ key: getStateKey() }, '');
// Fix for #2195 Add optional third attribute to workaround a bug in safari https://bugs.webkit.org/show_bug.cgi?id=182678
window.history.replaceState({ key: getStateKey() }, '', window.location.href.replace(window.location.origin, ''));
window.addEventListener('popstate', function (e) {
saveScrollPosition();
if (e.state && e.state.key) {
......@@ -1560,7 +1552,7 @@ function handleScroll (
// wait until re-render finishes before scrolling
router.app.$nextTick(function () {
var position = getScrollPosition();
var shouldScroll = behavior(to, from, isPop ? position : null);
var shouldScroll = behavior.call(router, to, from, isPop ? position : null);
if (!shouldScroll) {
return
......@@ -2122,7 +2114,10 @@ function poll (
key,
isValid
) {
if (instances[key]) {
if (
instances[key] &&
!instances[key]._isBeingDestroyed // do not reuse being destroyed instance
) {
cb(instances[key]);
} else if (isValid()) {
setTimeout(function () {
......@@ -2133,7 +2128,6 @@ function poll (
/* */
var HTML5History = (function (History$$1) {
function HTML5History (router, base) {
var this$1 = this;
......@@ -2141,8 +2135,9 @@ var HTML5History = (function (History$$1) {
History$$1.call(this, router, base);
var expectScroll = router.options.scrollBehavior;
var supportsScroll = supportsPushState && expectScroll;
if (expectScroll) {
if (supportsScroll) {
setupScroll();
}
......@@ -2158,7 +2153,7 @@ var HTML5History = (function (History$$1) {
}
this$1.transitionTo(location, function (route) {
if (expectScroll) {
if (supportsScroll) {
handleScroll(router, route, current, true);
}
});
......@@ -2212,7 +2207,7 @@ var HTML5History = (function (History$$1) {
}(History));
function getLocation (base) {
var path = window.location.pathname;
var path = decodeURI(window.location.pathname);
if (base && path.indexOf(base) === 0) {
path = path.slice(base.length);
}
......@@ -2221,7 +2216,6 @@ function getLocation (base) {
/* */
var HashHistory = (function (History$$1) {
function HashHistory (router, base, fallback) {
History$$1.call(this, router, base);
......@@ -2331,7 +2325,7 @@ function getHash () {
// consistent across browsers - Firefox will pre-decode it!
var href = window.location.href;
var index = href.indexOf('#');
return index === -1 ? '' : href.slice(index + 1)
return index === -1 ? '' : decodeURI(href.slice(index + 1))
}
function getUrl (path) {
......@@ -2359,7 +2353,6 @@ function replaceHash (path) {
/* */
var AbstractHistory = (function (History$$1) {
function AbstractHistory (router, base) {
History$$1.call(this, router, base);
......@@ -2418,6 +2411,8 @@ var AbstractHistory = (function (History$$1) {
/* */
var VueRouter = function VueRouter (options) {
if ( options === void 0 ) options = {};
......@@ -2614,7 +2609,7 @@ function createHref (base, fullPath, mode) {
}
VueRouter.install = install;
VueRouter.version = '3.0.1';
VueRouter.version = '3.0.2';
if (inBrowser && window.Vue) {
window.Vue.use(VueRouter);
......
/**
* vue-router v3.0.1
* (c) 2017 Evan You
/*!
* vue-router v3.0.2
* (c) 2018 Evan You
* @license MIT
*/
(function (global, factory) {
......@@ -27,8 +27,15 @@ function isError (err) {
return Object.prototype.toString.call(err).indexOf('Error') > -1
}
function extend (a, b) {
for (var key in b) {
a[key] = b[key];
}
return a
}
var View = {
name: 'router-view',
name: 'RouterView',
functional: true,
props: {
name: {
......@@ -42,6 +49,7 @@ var View = {
var parent = ref.parent;
var data = ref.data;
// used by devtools to display a router-view badge
data.routerView = true;
// directly use parent context's createElement() function
......@@ -116,7 +124,7 @@ var View = {
return h(component, data, children)
}
};
}
function resolveProps (route, config) {
switch (typeof config) {
......@@ -139,13 +147,6 @@ function resolveProps (route, config) {
}
}
function extend (to, from) {
for (var key in from) {
to[key] = from[key];
}
return to
}
/* */
var encodeReserveRE = /[!'()*]/g;
......@@ -244,7 +245,6 @@ function stringifyQuery (obj) {
/* */
var trailingSlashRE = /\/?$/;
function createRoute (
......@@ -387,7 +387,7 @@ var toTypes = [String, Object];
var eventTypes = [String, Array];
var Link = {
name: 'router-link',
name: 'RouterLink',
props: {
to: {
type: toTypes,
......@@ -422,17 +422,17 @@ var Link = {
var globalExactActiveClass = router.options.linkExactActiveClass;
// Support global empty active class
var activeClassFallback = globalActiveClass == null
? 'router-link-active'
: globalActiveClass;
? 'router-link-active'
: globalActiveClass;
var exactActiveClassFallback = globalExactActiveClass == null
? 'router-link-exact-active'
: globalExactActiveClass;
? 'router-link-exact-active'
: globalExactActiveClass;