1
1
/*!
2
- * vue-router v3.1.2
2
+ * vue-router v3.1.3
3
3
* (c) 2019 Evan You
4
4
* @license MIT
5
5
*/
@@ -142,7 +142,7 @@ var View = {
142
142
143
143
return h ( component , data , children )
144
144
}
145
- }
145
+ } ;
146
146
147
147
function resolveProps ( route , config ) {
148
148
switch ( typeof config ) {
@@ -271,7 +271,7 @@ function createRoute (
271
271
redirectedFrom ,
272
272
router
273
273
) {
274
- var stringifyQuery$$1 = router && router . options . stringifyQuery ;
274
+ var stringifyQuery = router && router . options . stringifyQuery ;
275
275
276
276
var query = location . query || { } ;
277
277
try {
@@ -285,11 +285,11 @@ function createRoute (
285
285
hash : location . hash || '' ,
286
286
query : query ,
287
287
params : location . params || { } ,
288
- fullPath : getFullPath ( location , stringifyQuery$$1 ) ,
288
+ fullPath : getFullPath ( location , stringifyQuery ) ,
289
289
matched : record ? formatMatch ( record ) : [ ]
290
290
} ;
291
291
if ( redirectedFrom ) {
292
- route . redirectedFrom = getFullPath ( redirectedFrom , stringifyQuery$$1 ) ;
292
+ route . redirectedFrom = getFullPath ( redirectedFrom , stringifyQuery ) ;
293
293
}
294
294
return Object . freeze ( route )
295
295
}
@@ -1116,7 +1116,24 @@ var Link = {
1116
1116
// in case the <a> is a static node
1117
1117
a . isStatic = false ;
1118
1118
var aData = ( a . data = extend ( { } , a . data ) ) ;
1119
- aData . on = on ;
1119
+ aData . on = aData . on || { } ;
1120
+ // transform existing events in both objects into arrays so we can push later
1121
+ for ( var event in aData . on ) {
1122
+ var handler$1 = aData . on [ event ] ;
1123
+ if ( event in on ) {
1124
+ aData . on [ event ] = Array . isArray ( handler$1 ) ? handler$1 : [ handler$1 ] ;
1125
+ }
1126
+ }
1127
+ // append new listeners for router-link
1128
+ for ( var event$1 in on ) {
1129
+ if ( event$1 in aData . on ) {
1130
+ // on[event] is always a function
1131
+ aData . on [ event$1 ] . push ( on [ event$1 ] ) ;
1132
+ } else {
1133
+ aData . on [ event$1 ] = handler ;
1134
+ }
1135
+ }
1136
+
1120
1137
var aAttrs = ( a . data . attrs = extend ( { } , a . data . attrs ) ) ;
1121
1138
aAttrs . href = href ;
1122
1139
} else {
@@ -1127,7 +1144,7 @@ var Link = {
1127
1144
1128
1145
return h ( this . tag , data , this . $slots . default )
1129
1146
}
1130
- }
1147
+ } ;
1131
1148
1132
1149
function guardEvent ( e ) {
1133
1150
// don't redirect with control keys
@@ -1245,6 +1262,18 @@ function createRouteMap (
1245
1262
}
1246
1263
}
1247
1264
1265
+ if ( process . env . NODE_ENV === 'development' ) {
1266
+ // warn if routes do not include leading slashes
1267
+ var found = pathList
1268
+ // check for missing leading slash
1269
+ . filter ( function ( path ) { return path && path . charAt ( 0 ) !== '*' && path . charAt ( 0 ) !== '/' ; } ) ;
1270
+
1271
+ if ( found . length > 0 ) {
1272
+ var pathNames = found . map ( function ( path ) { return ( "- " + path ) ; } ) . join ( '\n' ) ;
1273
+ warn ( false , ( "Non-nested routes must include a leading slash character. Fix the following routes: \n" + pathNames ) ) ;
1274
+ }
1275
+ }
1276
+
1248
1277
return {
1249
1278
pathList : pathList ,
1250
1279
pathMap : pathMap ,
@@ -1600,6 +1629,28 @@ function resolveRecordPath (path, record) {
1600
1629
1601
1630
/* */
1602
1631
1632
+ // use User Timing api (if present) for more accurate key precision
1633
+ var Time =
1634
+ inBrowser && window . performance && window . performance . now
1635
+ ? window . performance
1636
+ : Date ;
1637
+
1638
+ function genStateKey ( ) {
1639
+ return Time . now ( ) . toFixed ( 3 )
1640
+ }
1641
+
1642
+ var _key = genStateKey ( ) ;
1643
+
1644
+ function getStateKey ( ) {
1645
+ return _key
1646
+ }
1647
+
1648
+ function setStateKey ( key ) {
1649
+ return ( _key = key )
1650
+ }
1651
+
1652
+ /* */
1653
+
1603
1654
var positionStore = Object . create ( null ) ;
1604
1655
1605
1656
function setupScroll ( ) {
@@ -1749,39 +1800,22 @@ function scrollToPosition (shouldScroll, position) {
1749
1800
1750
1801
/* */
1751
1802
1752
- var supportsPushState = inBrowser && ( function ( ) {
1753
- var ua = window . navigator . userAgent ;
1754
-
1755
- if (
1756
- ( ua . indexOf ( 'Android 2.' ) !== - 1 || ua . indexOf ( 'Android 4.0' ) !== - 1 ) &&
1757
- ua . indexOf ( 'Mobile Safari' ) !== - 1 &&
1758
- ua . indexOf ( 'Chrome' ) === - 1 &&
1759
- ua . indexOf ( 'Windows Phone' ) === - 1
1760
- ) {
1761
- return false
1762
- }
1763
-
1764
- return window . history && 'pushState' in window . history
1765
- } ) ( ) ;
1766
-
1767
- // use User Timing api (if present) for more accurate key precision
1768
- var Time = inBrowser && window . performance && window . performance . now
1769
- ? window . performance
1770
- : Date ;
1771
-
1772
- var _key = genKey ( ) ;
1773
-
1774
- function genKey ( ) {
1775
- return Time . now ( ) . toFixed ( 3 )
1776
- }
1777
-
1778
- function getStateKey ( ) {
1779
- return _key
1780
- }
1803
+ var supportsPushState =
1804
+ inBrowser &&
1805
+ ( function ( ) {
1806
+ var ua = window . navigator . userAgent ;
1807
+
1808
+ if (
1809
+ ( ua . indexOf ( 'Android 2.' ) !== - 1 || ua . indexOf ( 'Android 4.0' ) !== - 1 ) &&
1810
+ ua . indexOf ( 'Mobile Safari' ) !== - 1 &&
1811
+ ua . indexOf ( 'Chrome' ) === - 1 &&
1812
+ ua . indexOf ( 'Windows Phone' ) === - 1
1813
+ ) {
1814
+ return false
1815
+ }
1781
1816
1782
- function setStateKey ( key ) {
1783
- _key = key ;
1784
- }
1817
+ return window . history && 'pushState' in window . history
1818
+ } ) ( ) ;
1785
1819
1786
1820
function pushState ( url , replace ) {
1787
1821
saveScrollPosition ( ) ;
@@ -1790,10 +1824,9 @@ function pushState (url, replace) {
1790
1824
var history = window . history ;
1791
1825
try {
1792
1826
if ( replace ) {
1793
- history . replaceState ( { key : _key } , '' , url ) ;
1827
+ history . replaceState ( { key : getStateKey ( ) } , '' , url ) ;
1794
1828
} else {
1795
- _key = genKey ( ) ;
1796
- history . pushState ( { key : _key } , '' , url ) ;
1829
+ history . pushState ( { key : setStateKey ( genStateKey ( ) ) } , '' , url ) ;
1797
1830
}
1798
1831
} catch ( e ) {
1799
1832
window . location [ replace ? 'replace' : 'assign' ] ( url ) ;
@@ -1933,9 +1966,20 @@ function once (fn) {
1933
1966
}
1934
1967
1935
1968
var NavigationDuplicated = /*@__PURE__ */ ( function ( Error ) {
1936
- function NavigationDuplicated ( ) {
1937
- Error . call ( this , 'Navigating to current location is not allowed' ) ;
1969
+ function NavigationDuplicated ( normalizedLocation ) {
1970
+ Error . call ( this ) ;
1938
1971
this . name = this . _name = 'NavigationDuplicated' ;
1972
+ // passing the message to super() doesn't seem to work in the transpiled version
1973
+ this . message = "Navigating to current location (\"" + ( normalizedLocation . fullPath ) + "\") is not allowed" ;
1974
+ // add a stack property so services like Sentry can correctly display it
1975
+ Object . defineProperty ( this , 'stack' , {
1976
+ value : new Error ( ) . stack ,
1977
+ writable : true ,
1978
+ configurable : true
1979
+ } ) ;
1980
+ // we could also have used
1981
+ // Error.captureStackTrace(this, this.constructor)
1982
+ // but it only exists on node and chrome
1939
1983
}
1940
1984
1941
1985
if ( Error ) NavigationDuplicated . __proto__ = Error ;
@@ -2275,11 +2319,11 @@ function poll (
2275
2319
2276
2320
/* */
2277
2321
2278
- var HTML5History = /*@__PURE__ */ ( function ( History$$1 ) {
2322
+ var HTML5History = /*@__PURE__ */ ( function ( History ) {
2279
2323
function HTML5History ( router , base ) {
2280
2324
var this$1 = this ;
2281
2325
2282
- History$$1 . call ( this , router , base ) ;
2326
+ History . call ( this , router , base ) ;
2283
2327
2284
2328
var expectScroll = router . options . scrollBehavior ;
2285
2329
var supportsScroll = supportsPushState && expectScroll ;
@@ -2307,8 +2351,8 @@ var HTML5History = /*@__PURE__*/(function (History$$1) {
2307
2351
} ) ;
2308
2352
}
2309
2353
2310
- if ( History$$1 ) HTML5History . __proto__ = History$$1 ;
2311
- HTML5History . prototype = Object . create ( History$$1 && History$$1 . prototype ) ;
2354
+ if ( History ) HTML5History . __proto__ = History ;
2355
+ HTML5History . prototype = Object . create ( History && History . prototype ) ;
2312
2356
HTML5History . prototype . constructor = HTML5History ;
2313
2357
2314
2358
HTML5History . prototype . go = function go ( n ) {
@@ -2363,18 +2407,18 @@ function getLocation (base) {
2363
2407
2364
2408
/* */
2365
2409
2366
- var HashHistory = /*@__PURE__ */ ( function ( History$$1 ) {
2410
+ var HashHistory = /*@__PURE__ */ ( function ( History ) {
2367
2411
function HashHistory ( router , base , fallback ) {
2368
- History$$1 . call ( this , router , base ) ;
2412
+ History . call ( this , router , base ) ;
2369
2413
// check history fallback deeplinking
2370
2414
if ( fallback && checkFallback ( this . base ) ) {
2371
2415
return
2372
2416
}
2373
2417
ensureSlash ( ) ;
2374
2418
}
2375
2419
2376
- if ( History$$1 ) HashHistory . __proto__ = History$$1 ;
2377
- HashHistory . prototype = Object . create ( History$$1 && History$$1 . prototype ) ;
2420
+ if ( History ) HashHistory . __proto__ = History ;
2421
+ HashHistory . prototype = Object . create ( History && History . prototype ) ;
2378
2422
HashHistory . prototype . constructor = HashHistory ;
2379
2423
2380
2424
// this is delayed until the app mounts
@@ -2528,15 +2572,15 @@ function replaceHash (path) {
2528
2572
2529
2573
/* */
2530
2574
2531
- var AbstractHistory = /*@__PURE__ */ ( function ( History$$1 ) {
2575
+ var AbstractHistory = /*@__PURE__ */ ( function ( History ) {
2532
2576
function AbstractHistory ( router , base ) {
2533
- History$$1 . call ( this , router , base ) ;
2577
+ History . call ( this , router , base ) ;
2534
2578
this . stack = [ ] ;
2535
2579
this . index = - 1 ;
2536
2580
}
2537
2581
2538
- if ( History$$1 ) AbstractHistory . __proto__ = History$$1 ;
2539
- AbstractHistory . prototype = Object . create ( History$$1 && History$$1 . prototype ) ;
2582
+ if ( History ) AbstractHistory . __proto__ = History ;
2583
+ AbstractHistory . prototype = Object . create ( History && History . prototype ) ;
2540
2584
AbstractHistory . prototype . constructor = AbstractHistory ;
2541
2585
2542
2586
AbstractHistory . prototype . push = function push ( location , onComplete , onAbort ) {
@@ -2831,7 +2875,7 @@ function createHref (base, fullPath, mode) {
2831
2875
}
2832
2876
2833
2877
VueRouter . install = install ;
2834
- VueRouter . version = '3.1.2 ' ;
2878
+ VueRouter . version = '3.1.3 ' ;
2835
2879
2836
2880
if ( inBrowser && window . Vue ) {
2837
2881
window . Vue . use ( VueRouter ) ;
0 commit comments