vuejs-rails 1.0.24 → 1.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * vue-router v0.7.10
2
+ * vue-router v0.7.13
3
3
  * (c) 2016 Evan You
4
4
  * Released under the MIT License.
5
5
  */
@@ -125,6 +125,21 @@
125
125
 
126
126
  var escapeRegex = new RegExp('(\\' + specials.join('|\\') + ')', 'g');
127
127
 
128
+ var noWarning = false;
129
+ function warn(msg) {
130
+ if (!noWarning && typeof console !== 'undefined') {
131
+ console.error('[vue-router] ' + msg);
132
+ }
133
+ }
134
+
135
+ function tryDecode(uri, asComponent) {
136
+ try {
137
+ return asComponent ? decodeURIComponent(uri) : decodeURI(uri);
138
+ } catch (e) {
139
+ warn('malformed URI' + (asComponent ? ' component: ' : ': ') + uri);
140
+ }
141
+ }
142
+
128
143
  function isArray(test) {
129
144
  return Object.prototype.toString.call(test) === "[object Array]";
130
145
  }
@@ -465,7 +480,7 @@
465
480
  function decodeQueryParamPart(part) {
466
481
  // http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1
467
482
  part = part.replace(/\+/gm, '%20');
468
- return decodeURIComponent(part);
483
+ return tryDecode(part, true);
469
484
  }
470
485
 
471
486
  // The main interface
@@ -647,7 +662,8 @@
647
662
  return queryParams;
648
663
  },
649
664
 
650
- recognize: function recognize(path) {
665
+ recognize: function recognize(path, silent) {
666
+ noWarning = silent;
651
667
  var states = [this.rootState],
652
668
  pathLen,
653
669
  i,
@@ -660,10 +676,13 @@
660
676
  if (queryStart !== -1) {
661
677
  var queryString = path.substr(queryStart + 1, path.length);
662
678
  path = path.substr(0, queryStart);
663
- queryParams = this.parseQueryString(queryString);
679
+ if (queryString) {
680
+ queryParams = this.parseQueryString(queryString);
681
+ }
664
682
  }
665
683
 
666
- path = decodeURI(path);
684
+ path = tryDecode(path);
685
+ if (!path) return;
667
686
 
668
687
  // DEBUG GROUP path
669
688
 
@@ -710,8 +729,6 @@
710
729
 
711
730
  RouteRecognizer.prototype.map = map;
712
731
 
713
- RouteRecognizer.VERSION = '0.1.9';
714
-
715
732
  var genQuery = RouteRecognizer.prototype.generateQueryString;
716
733
 
717
734
  // export default for holding the Vue reference
@@ -722,13 +739,10 @@
722
739
  * @param {String} msg
723
740
  */
724
741
 
725
- function warn(msg) {
742
+ function warn$1(msg) {
726
743
  /* istanbul ignore next */
727
- if (window.console) {
728
- console.warn('[vue-router] ' + msg);
729
- if (!exports$1.Vue || exports$1.Vue.config.debug) {
730
- console.warn(new Error('warning stack trace:').stack);
731
- }
744
+ if (typeof console !== 'undefined') {
745
+ console.error('[vue-router] ' + msg);
732
746
  }
733
747
  }
734
748
 
@@ -847,7 +861,7 @@
847
861
  var val = params[key];
848
862
  /* istanbul ignore if */
849
863
  if (!val) {
850
- warn('param "' + key + '" not found when generating ' + 'path for "' + path + '" with params ' + JSON.stringify(params));
864
+ warn$1('param "' + key + '" not found when generating ' + 'path for "' + path + '" with params ' + JSON.stringify(params));
851
865
  }
852
866
  return val || '';
853
867
  });
@@ -865,7 +879,7 @@
865
879
  var onChange = _ref.onChange;
866
880
  babelHelpers.classCallCheck(this, HTML5History);
867
881
 
868
- if (root) {
882
+ if (root && root !== '/') {
869
883
  // make sure there's the starting slash
870
884
  if (root.charAt(0) !== '/') {
871
885
  root = '/' + root;
@@ -886,7 +900,7 @@
886
900
  var _this = this;
887
901
 
888
902
  this.listener = function (e) {
889
- var url = decodeURI(location.pathname + location.search);
903
+ var url = location.pathname + location.search;
890
904
  if (_this.root) {
891
905
  url = url.replace(_this.rootRE, '');
892
906
  }
@@ -911,7 +925,7 @@
911
925
  x: window.pageXOffset,
912
926
  y: window.pageYOffset
913
927
  }
914
- }, '');
928
+ }, '', location.href);
915
929
  // then push new state
916
930
  history.pushState({}, '', url);
917
931
  }
@@ -962,7 +976,7 @@
962
976
  // note it's possible to have queries in both the actual URL
963
977
  // and the hash fragment itself.
964
978
  var query = location.search && path.indexOf('?') > -1 ? '&' + location.search.slice(1) : location.search;
965
- self.onChange(decodeURI(path.replace(/^#!?/, '') + query));
979
+ self.onChange(path.replace(/^#!?/, '') + query);
966
980
  };
967
981
  window.addEventListener('hashchange', this.listener);
968
982
  this.listener();
@@ -1236,7 +1250,10 @@
1236
1250
  };
1237
1251
 
1238
1252
  if (activateHook) {
1239
- transition.callHooks(activateHook, component, afterActivate, { cleanup: cleanup });
1253
+ transition.callHooks(activateHook, component, afterActivate, {
1254
+ cleanup: cleanup,
1255
+ postActivate: true
1256
+ });
1240
1257
  } else {
1241
1258
  afterActivate();
1242
1259
  }
@@ -1269,46 +1286,32 @@
1269
1286
 
1270
1287
  function loadData(component, transition, hook, cb, cleanup) {
1271
1288
  component.$loadingRouteData = true;
1272
- transition.callHooks(hook, component, function (data, onError) {
1273
- // merge data from multiple data hooks
1274
- if (Array.isArray(data) && data._needMerge) {
1275
- data = data.reduce(function (res, obj) {
1276
- if (isPlainObject(obj)) {
1277
- Object.keys(obj).forEach(function (key) {
1278
- res[key] = obj[key];
1279
- });
1280
- }
1281
- return res;
1282
- }, Object.create(null));
1283
- }
1284
- // handle promise sugar syntax
1285
- var promises = [];
1286
- if (isPlainObject(data)) {
1287
- Object.keys(data).forEach(function (key) {
1288
- var val = data[key];
1289
- if (isPromise(val)) {
1290
- promises.push(val.then(function (resolvedVal) {
1291
- component.$set(key, resolvedVal);
1292
- }));
1293
- } else {
1294
- component.$set(key, val);
1295
- }
1296
- });
1297
- }
1298
- if (!promises.length) {
1299
- component.$loadingRouteData = false;
1300
- component.$emit('route-data-loaded', component);
1301
- cb && cb();
1302
- } else {
1303
- promises[0].constructor.all(promises).then(function () {
1304
- component.$loadingRouteData = false;
1305
- component.$emit('route-data-loaded', component);
1306
- cb && cb();
1307
- }, onError);
1308
- }
1289
+ transition.callHooks(hook, component, function () {
1290
+ component.$loadingRouteData = false;
1291
+ component.$emit('route-data-loaded', component);
1292
+ cb && cb();
1309
1293
  }, {
1310
1294
  cleanup: cleanup,
1311
- expectData: true
1295
+ postActivate: true,
1296
+ processData: function processData(data) {
1297
+ // handle promise sugar syntax
1298
+ var promises = [];
1299
+ if (isPlainObject(data)) {
1300
+ Object.keys(data).forEach(function (key) {
1301
+ var val = data[key];
1302
+ if (isPromise(val)) {
1303
+ promises.push(val.then(function (resolvedVal) {
1304
+ component.$set(key, resolvedVal);
1305
+ }));
1306
+ } else {
1307
+ component.$set(key, val);
1308
+ }
1309
+ });
1310
+ }
1311
+ if (promises.length) {
1312
+ return promises[0].constructor.all(promises);
1313
+ }
1314
+ }
1312
1315
  });
1313
1316
  }
1314
1317
 
@@ -1518,7 +1521,8 @@
1518
1521
  * @param {Function} [cb]
1519
1522
  * @param {Object} [options]
1520
1523
  * - {Boolean} expectBoolean
1521
- * - {Boolean} expectData
1524
+ * - {Boolean} postActive
1525
+ * - {Function} processData
1522
1526
  * - {Function} cleanup
1523
1527
  */
1524
1528
 
@@ -1527,8 +1531,9 @@
1527
1531
 
1528
1532
  var _ref$expectBoolean = _ref.expectBoolean;
1529
1533
  var expectBoolean = _ref$expectBoolean === undefined ? false : _ref$expectBoolean;
1530
- var _ref$expectData = _ref.expectData;
1531
- var expectData = _ref$expectData === undefined ? false : _ref$expectData;
1534
+ var _ref$postActivate = _ref.postActivate;
1535
+ var postActivate = _ref$postActivate === undefined ? false : _ref$postActivate;
1536
+ var processData = _ref.processData;
1532
1537
  var cleanup = _ref.cleanup;
1533
1538
 
1534
1539
  var transition = this;
@@ -1542,20 +1547,29 @@
1542
1547
 
1543
1548
  // handle errors
1544
1549
  var onError = function onError(err) {
1545
- // cleanup indicates an after-activation hook,
1546
- // so instead of aborting we just let the transition
1547
- // finish.
1548
- cleanup ? next() : abort();
1550
+ postActivate ? next() : abort();
1549
1551
  if (err && !transition.router._suppress) {
1550
- warn('Uncaught error during transition: ');
1552
+ warn$1('Uncaught error during transition: ');
1551
1553
  throw err instanceof Error ? err : new Error(err);
1552
1554
  }
1553
1555
  };
1554
1556
 
1557
+ // since promise swallows errors, we have to
1558
+ // throw it in the next tick...
1559
+ var onPromiseError = function onPromiseError(err) {
1560
+ try {
1561
+ onError(err);
1562
+ } catch (e) {
1563
+ setTimeout(function () {
1564
+ throw e;
1565
+ }, 0);
1566
+ }
1567
+ };
1568
+
1555
1569
  // advance the transition to the next step
1556
- var next = function next(data) {
1570
+ var next = function next() {
1557
1571
  if (nextCalled) {
1558
- warn('transition.next() should be called only once.');
1572
+ warn$1('transition.next() should be called only once.');
1559
1573
  return;
1560
1574
  }
1561
1575
  nextCalled = true;
@@ -1563,7 +1577,33 @@
1563
1577
  cleanup && cleanup();
1564
1578
  return;
1565
1579
  }
1566
- cb && cb(data, onError);
1580
+ cb && cb();
1581
+ };
1582
+
1583
+ var nextWithBoolean = function nextWithBoolean(res) {
1584
+ if (typeof res === 'boolean') {
1585
+ res ? next() : abort();
1586
+ } else if (isPromise(res)) {
1587
+ res.then(function (ok) {
1588
+ ok ? next() : abort();
1589
+ }, onPromiseError);
1590
+ } else if (!hook.length) {
1591
+ next();
1592
+ }
1593
+ };
1594
+
1595
+ var nextWithData = function nextWithData(data) {
1596
+ var res = undefined;
1597
+ try {
1598
+ res = processData(data);
1599
+ } catch (err) {
1600
+ return onError(err);
1601
+ }
1602
+ if (isPromise(res)) {
1603
+ res.then(next, onPromiseError);
1604
+ } else {
1605
+ next();
1606
+ }
1567
1607
  };
1568
1608
 
1569
1609
  // expose a clone of the transition object, so that each
@@ -1573,7 +1613,7 @@
1573
1613
  to: transition.to,
1574
1614
  from: transition.from,
1575
1615
  abort: abort,
1576
- next: next,
1616
+ next: processData ? nextWithData : next,
1577
1617
  redirect: function redirect() {
1578
1618
  transition.redirect.apply(transition, arguments);
1579
1619
  }
@@ -1587,22 +1627,21 @@
1587
1627
  return onError(err);
1588
1628
  }
1589
1629
 
1590
- // handle boolean/promise return values
1591
- var resIsPromise = isPromise(res);
1592
1630
  if (expectBoolean) {
1593
- if (typeof res === 'boolean') {
1594
- res ? next() : abort();
1595
- } else if (resIsPromise) {
1596
- res.then(function (ok) {
1597
- ok ? next() : abort();
1598
- }, onError);
1599
- } else if (!hook.length) {
1600
- next(res);
1631
+ // boolean hooks
1632
+ nextWithBoolean(res);
1633
+ } else if (isPromise(res)) {
1634
+ // promise
1635
+ if (processData) {
1636
+ res.then(nextWithData, onPromiseError);
1637
+ } else {
1638
+ res.then(next, onPromiseError);
1601
1639
  }
1602
- } else if (resIsPromise) {
1603
- res.then(next, onError);
1604
- } else if (expectData && isPlainOjbect(res) || !hook.length) {
1605
- next(res);
1640
+ } else if (processData && isPlainOjbect(res)) {
1641
+ // data promise sugar
1642
+ nextWithData(res);
1643
+ } else if (!hook.length) {
1644
+ next();
1606
1645
  }
1607
1646
  };
1608
1647
 
@@ -1619,22 +1658,11 @@
1619
1658
  var _this = this;
1620
1659
 
1621
1660
  if (Array.isArray(hooks)) {
1622
- (function () {
1623
- var res = [];
1624
- res._needMerge = true;
1625
- var onError = undefined;
1626
- _this.runQueue(hooks, function (hook, _, next) {
1627
- if (!_this.aborted) {
1628
- _this.callHook(hook, context, function (r, onError) {
1629
- if (r) res.push(r);
1630
- onError = onError;
1631
- next();
1632
- }, options);
1633
- }
1634
- }, function () {
1635
- cb(res, onError);
1636
- });
1637
- })();
1661
+ this.runQueue(hooks, function (hook, _, next) {
1662
+ if (!_this.aborted) {
1663
+ _this.callHook(hook, context, next, options);
1664
+ }
1665
+ }, cb);
1638
1666
  } else {
1639
1667
  this.callHook(hooks, context, cb, options);
1640
1668
  }
@@ -1651,7 +1679,7 @@
1651
1679
  return val ? Array.prototype.slice.call(val) : [];
1652
1680
  }
1653
1681
 
1654
- var internalKeysRE = /^(component|subRoutes)$/;
1682
+ var internalKeysRE = /^(component|subRoutes|fullPath)$/;
1655
1683
 
1656
1684
  /**
1657
1685
  * Route Context Object
@@ -1688,9 +1716,13 @@
1688
1716
  }
1689
1717
  // expose path and router
1690
1718
  this.path = path;
1691
- this.router = router;
1692
1719
  // for internal use
1693
1720
  this.matched = matched || router._notFoundHandler;
1721
+ // internal reference to router
1722
+ Object.defineProperty(this, 'router', {
1723
+ enumerable: false,
1724
+ value: router
1725
+ });
1694
1726
  // Important: freeze self to prevent observation
1695
1727
  Object.freeze(this);
1696
1728
  };
@@ -1778,7 +1810,7 @@
1778
1810
  var route = this.vm.$route;
1779
1811
  /* istanbul ignore if */
1780
1812
  if (!route) {
1781
- warn('<router-view> can only be used inside a ' + 'router-enabled app.');
1813
+ warn$1('<router-view> can only be used inside a ' + 'router-enabled app.');
1782
1814
  return;
1783
1815
  }
1784
1816
  // force dynamic directive so v-component doesn't
@@ -1847,35 +1879,58 @@
1847
1879
  var addClass = _Vue$util.addClass;
1848
1880
  var removeClass = _Vue$util.removeClass;
1849
1881
 
1882
+ var onPriority = Vue.directive('on').priority;
1883
+ var LINK_UPDATE = '__vue-router-link-update__';
1884
+
1885
+ var activeId = 0;
1886
+
1850
1887
  Vue.directive('link-active', {
1851
- priority: 1001,
1888
+ priority: 9999,
1852
1889
  bind: function bind() {
1853
- this.el.__v_link_active = true;
1890
+ var _this = this;
1891
+
1892
+ var id = String(activeId++);
1893
+ // collect v-links contained within this element.
1894
+ // we need do this here before the parent-child relationship
1895
+ // gets messed up by terminal directives (if, for, components)
1896
+ var childLinks = this.el.querySelectorAll('[v-link]');
1897
+ for (var i = 0, l = childLinks.length; i < l; i++) {
1898
+ var link = childLinks[i];
1899
+ var existingId = link.getAttribute(LINK_UPDATE);
1900
+ var value = existingId ? existingId + ',' + id : id;
1901
+ // leave a mark on the link element which can be persisted
1902
+ // through fragment clones.
1903
+ link.setAttribute(LINK_UPDATE, value);
1904
+ }
1905
+ this.vm.$on(LINK_UPDATE, this.cb = function (link, path) {
1906
+ if (link.activeIds.indexOf(id) > -1) {
1907
+ link.updateClasses(path, _this.el);
1908
+ }
1909
+ });
1910
+ },
1911
+ unbind: function unbind() {
1912
+ this.vm.$off(LINK_UPDATE, this.cb);
1854
1913
  }
1855
1914
  });
1856
1915
 
1857
1916
  Vue.directive('link', {
1858
- priority: 1000,
1917
+ priority: onPriority - 2,
1859
1918
 
1860
1919
  bind: function bind() {
1861
1920
  var vm = this.vm;
1862
1921
  /* istanbul ignore if */
1863
1922
  if (!vm.$route) {
1864
- warn('v-link can only be used inside a router-enabled app.');
1923
+ warn$1('v-link can only be used inside a router-enabled app.');
1865
1924
  return;
1866
1925
  }
1867
1926
  this.router = vm.$route.router;
1868
1927
  // update things when the route changes
1869
1928
  this.unwatch = vm.$watch('$route', _bind(this.onRouteUpdate, this));
1870
- // check if active classes should be applied to a different element
1871
- this.activeEl = this.el;
1872
- var parent = this.el.parentNode;
1873
- while (parent) {
1874
- if (parent.__v_link_active) {
1875
- this.activeEl = parent;
1876
- break;
1877
- }
1878
- parent = parent.parentNode;
1929
+ // check v-link-active ids
1930
+ var activeIds = this.el.getAttribute(LINK_UPDATE);
1931
+ if (activeIds) {
1932
+ this.el.removeAttribute(LINK_UPDATE);
1933
+ this.activeIds = activeIds.split(',');
1879
1934
  }
1880
1935
  // no need to handle click if link expects to be opened
1881
1936
  // in a new window/tab.
@@ -1884,7 +1939,8 @@
1884
1939
  return;
1885
1940
  }
1886
1941
  // handle click
1887
- this.el.addEventListener('click', _bind(this.onClick, this));
1942
+ this.handler = _bind(this.onClick, this);
1943
+ this.el.addEventListener('click', this.handler);
1888
1944
  },
1889
1945
 
1890
1946
  update: function update(target) {
@@ -1922,8 +1978,12 @@
1922
1978
  }
1923
1979
  if (el.tagName === 'A' && sameOrigin(el)) {
1924
1980
  e.preventDefault();
1981
+ var path = el.pathname;
1982
+ if (this.router.history.root) {
1983
+ path = path.replace(this.router.history.rootRE, '');
1984
+ }
1925
1985
  this.router.go({
1926
- path: el.pathname,
1986
+ path: path,
1927
1987
  replace: target && target.replace,
1928
1988
  append: target && target.append
1929
1989
  });
@@ -1932,15 +1992,19 @@
1932
1992
  },
1933
1993
 
1934
1994
  onRouteUpdate: function onRouteUpdate(route) {
1935
- // router._stringifyPath is dependent on current route
1995
+ // router.stringifyPath is dependent on current route
1936
1996
  // and needs to be called again whenver route changes.
1937
- var newPath = this.router._stringifyPath(this.target);
1997
+ var newPath = this.router.stringifyPath(this.target);
1938
1998
  if (this.path !== newPath) {
1939
1999
  this.path = newPath;
1940
2000
  this.updateActiveMatch();
1941
2001
  this.updateHref();
1942
2002
  }
1943
- this.updateClasses(route.path);
2003
+ if (this.activeIds) {
2004
+ this.vm.$emit(LINK_UPDATE, this, route.path);
2005
+ } else {
2006
+ this.updateClasses(route.path, this.el);
2007
+ }
1944
2008
  },
1945
2009
 
1946
2010
  updateActiveMatch: function updateActiveMatch() {
@@ -1963,12 +2027,11 @@
1963
2027
  }
1964
2028
  },
1965
2029
 
1966
- updateClasses: function updateClasses(path) {
1967
- var el = this.activeEl;
2030
+ updateClasses: function updateClasses(path, el) {
1968
2031
  var activeClass = this.activeClass || this.router._linkActiveClass;
1969
2032
  // clear old class
1970
- if (this.prevActiveClass !== activeClass) {
1971
- removeClass(el, this.prevActiveClass);
2033
+ if (this.prevActiveClass && this.prevActiveClass !== activeClass) {
2034
+ toggleClasses(el, this.prevActiveClass, removeClass);
1972
2035
  }
1973
2036
  // remove query string before matching
1974
2037
  var dest = this.path.replace(queryStringRE, '');
@@ -1978,15 +2041,15 @@
1978
2041
  if (dest === path ||
1979
2042
  // also allow additional trailing slash
1980
2043
  dest.charAt(dest.length - 1) !== '/' && dest === path.replace(trailingSlashRE, '')) {
1981
- addClass(el, activeClass);
2044
+ toggleClasses(el, activeClass, addClass);
1982
2045
  } else {
1983
- removeClass(el, activeClass);
2046
+ toggleClasses(el, activeClass, removeClass);
1984
2047
  }
1985
2048
  } else {
1986
2049
  if (this.activeRE && this.activeRE.test(path)) {
1987
- addClass(el, activeClass);
2050
+ toggleClasses(el, activeClass, addClass);
1988
2051
  } else {
1989
- removeClass(el, activeClass);
2052
+ toggleClasses(el, activeClass, removeClass);
1990
2053
  }
1991
2054
  }
1992
2055
  },
@@ -2000,6 +2063,20 @@
2000
2063
  function sameOrigin(link) {
2001
2064
  return link.protocol === location.protocol && link.hostname === location.hostname && link.port === location.port;
2002
2065
  }
2066
+
2067
+ // this function is copied from v-bind:class implementation until
2068
+ // we properly expose it...
2069
+ function toggleClasses(el, key, fn) {
2070
+ key = key.trim();
2071
+ if (key.indexOf(' ') === -1) {
2072
+ fn(el, key);
2073
+ return;
2074
+ }
2075
+ var keys = key.split(/\s+/);
2076
+ for (var i = 0, l = keys.length; i < l; i++) {
2077
+ fn(el, keys[i]);
2078
+ }
2079
+ }
2003
2080
  }
2004
2081
 
2005
2082
  var historyBackends = {
@@ -2208,7 +2285,7 @@
2208
2285
  replace = path.replace;
2209
2286
  append = path.append;
2210
2287
  }
2211
- path = this._stringifyPath(path);
2288
+ path = this.stringifyPath(path);
2212
2289
  if (path) {
2213
2290
  this.history.go(path, replace, append);
2214
2291
  }
@@ -2239,7 +2316,7 @@
2239
2316
  Router.prototype.start = function start(App, container, cb) {
2240
2317
  /* istanbul ignore if */
2241
2318
  if (this._started) {
2242
- warn('already started.');
2319
+ warn$1('already started.');
2243
2320
  return;
2244
2321
  }
2245
2322
  this._started = true;
@@ -2283,6 +2360,41 @@
2283
2360
  this._started = false;
2284
2361
  };
2285
2362
 
2363
+ /**
2364
+ * Normalize named route object / string paths into
2365
+ * a string.
2366
+ *
2367
+ * @param {Object|String|Number} path
2368
+ * @return {String}
2369
+ */
2370
+
2371
+ Router.prototype.stringifyPath = function stringifyPath(path) {
2372
+ var generatedPath = '';
2373
+ if (path && typeof path === 'object') {
2374
+ if (path.name) {
2375
+ var extend = Vue.util.extend;
2376
+ var currentParams = this._currentTransition && this._currentTransition.to.params;
2377
+ var targetParams = path.params || {};
2378
+ var params = currentParams ? extend(extend({}, currentParams), targetParams) : targetParams;
2379
+ generatedPath = encodeURI(this._recognizer.generate(path.name, params));
2380
+ } else if (path.path) {
2381
+ generatedPath = encodeURI(path.path);
2382
+ }
2383
+ if (path.query) {
2384
+ // note: the generated query string is pre-URL-encoded by the recognizer
2385
+ var query = this._recognizer.generateQueryString(path.query);
2386
+ if (generatedPath.indexOf('?') > -1) {
2387
+ generatedPath += '&' + query.slice(1);
2388
+ } else {
2389
+ generatedPath += query;
2390
+ }
2391
+ }
2392
+ } else {
2393
+ generatedPath = encodeURI(path ? path + '' : '');
2394
+ }
2395
+ return generatedPath;
2396
+ };
2397
+
2286
2398
  // Internal methods ======================================
2287
2399
 
2288
2400
  /**
@@ -2385,7 +2497,7 @@
2385
2497
  */
2386
2498
 
2387
2499
  Router.prototype._checkGuard = function _checkGuard(path) {
2388
- var matched = this._guardRecognizer.recognize(path);
2500
+ var matched = this._guardRecognizer.recognize(path, true);
2389
2501
  if (matched) {
2390
2502
  matched[0].handler(matched[0], matched.queryParams);
2391
2503
  return true;
@@ -2548,43 +2660,6 @@
2548
2660
  }
2549
2661
  };
2550
2662
 
2551
- /**
2552
- * Normalize named route object / string paths into
2553
- * a string.
2554
- *
2555
- * @param {Object|String|Number} path
2556
- * @return {String}
2557
- */
2558
-
2559
- Router.prototype._stringifyPath = function _stringifyPath(path) {
2560
- var fullPath = '';
2561
- if (path && typeof path === 'object') {
2562
- if (path.name) {
2563
- var extend = Vue.util.extend;
2564
- var currentParams = this._currentTransition && this._currentTransition.to.params;
2565
- var targetParams = path.params || {};
2566
- var params = currentParams ? extend(extend({}, currentParams), targetParams) : targetParams;
2567
- if (path.query) {
2568
- params.queryParams = path.query;
2569
- }
2570
- fullPath = this._recognizer.generate(path.name, params);
2571
- } else if (path.path) {
2572
- fullPath = path.path;
2573
- if (path.query) {
2574
- var query = this._recognizer.generateQueryString(path.query);
2575
- if (fullPath.indexOf('?') > -1) {
2576
- fullPath += '&' + query.slice(1);
2577
- } else {
2578
- fullPath += query;
2579
- }
2580
- }
2581
- }
2582
- } else {
2583
- fullPath = path ? path + '' : '';
2584
- }
2585
- return encodeURI(fullPath);
2586
- };
2587
-
2588
2663
  return Router;
2589
2664
  })();
2590
2665
 
@@ -2596,7 +2671,7 @@
2596
2671
  /* istanbul ignore if */
2597
2672
  if (typeof comp !== 'function') {
2598
2673
  handler.component = null;
2599
- warn('invalid component for route "' + path + '".');
2674
+ warn$1('invalid component for route "' + path + '".');
2600
2675
  }
2601
2676
  }
2602
2677
 
@@ -2612,7 +2687,7 @@
2612
2687
  Router.install = function (externalVue) {
2613
2688
  /* istanbul ignore if */
2614
2689
  if (Router.installed) {
2615
- warn('already installed.');
2690
+ warn$1('already installed.');
2616
2691
  return;
2617
2692
  }
2618
2693
  Vue = externalVue;