1- /**
2- * vue-router v3.0.1
3- * (c) 2017 Evan You
1+ /*!
2+ * vue-router v3.0.2
3+ * (c) 2018 Evan You
44 * @license MIT
55 */
66'use strict' ;
@@ -23,8 +23,15 @@ function isError (err) {
2323 return Object . prototype . toString . call ( err ) . indexOf ( 'Error' ) > - 1
2424}
2525
26+ function extend ( a , b ) {
27+ for ( var key in b ) {
28+ a [ key ] = b [ key ] ;
29+ }
30+ return a
31+ }
32+
2633var View = {
27- name : 'router-view ' ,
34+ name : 'RouterView ' ,
2835 functional : true ,
2936 props : {
3037 name : {
@@ -38,6 +45,7 @@ var View = {
3845 var parent = ref . parent ;
3946 var data = ref . data ;
4047
48+ // used by devtools to display a router-view badge
4149 data . routerView = true ;
4250
4351 // directly use parent context's createElement() function
@@ -112,7 +120,7 @@ var View = {
112120
113121 return h ( component , data , children )
114122 }
115- } ;
123+ }
116124
117125function resolveProps ( route , config ) {
118126 switch ( typeof config ) {
@@ -135,13 +143,6 @@ function resolveProps (route, config) {
135143 }
136144}
137145
138- function extend ( to , from ) {
139- for ( var key in from ) {
140- to [ key ] = from [ key ] ;
141- }
142- return to
143- }
144-
145146/* */
146147
147148var encodeReserveRE = / [ ! ' ( ) * ] / g;
@@ -240,7 +241,6 @@ function stringifyQuery (obj) {
240241
241242/* */
242243
243-
244244var trailingSlashRE = / \/ ? $ / ;
245245
246246function createRoute (
@@ -383,7 +383,7 @@ var toTypes = [String, Object];
383383var eventTypes = [ String , Array ] ;
384384
385385var Link = {
386- name : 'router-link ' ,
386+ name : 'RouterLink ' ,
387387 props : {
388388 to : {
389389 type : toTypes ,
@@ -418,17 +418,17 @@ var Link = {
418418 var globalExactActiveClass = router . options . linkExactActiveClass ;
419419 // Support global empty active class
420420 var activeClassFallback = globalActiveClass == null
421- ? 'router-link-active'
422- : globalActiveClass ;
421+ ? 'router-link-active'
422+ : globalActiveClass ;
423423 var exactActiveClassFallback = globalExactActiveClass == null
424- ? 'router-link-exact-active'
425- : globalExactActiveClass ;
424+ ? 'router-link-exact-active'
425+ : globalExactActiveClass ;
426426 var activeClass = this . activeClass == null
427- ? activeClassFallback
428- : this . activeClass ;
427+ ? activeClassFallback
428+ : this . activeClass ;
429429 var exactActiveClass = this . exactActiveClass == null
430- ? exactActiveClassFallback
431- : this . exactActiveClass ;
430+ ? exactActiveClassFallback
431+ : this . exactActiveClass ;
432432 var compareTarget = location . path
433433 ? createRoute ( null , location , null , router )
434434 : route ;
@@ -468,7 +468,6 @@ var Link = {
468468 if ( a ) {
469469 // in case the <a> is a static node
470470 a . isStatic = false ;
471- var extend = _Vue . util . extend ;
472471 var aData = a . data = extend ( { } , a . data ) ;
473472 aData . on = on ;
474473 var aAttrs = a . data . attrs = extend ( { } , a . data . attrs ) ;
@@ -481,7 +480,7 @@ var Link = {
481480
482481 return h ( this . tag , data , this . $slots . default )
483482 }
484- } ;
483+ }
485484
486485function guardEvent ( e ) {
487486 // don't redirect with control keys
@@ -559,8 +558,8 @@ function install (Vue) {
559558 get : function get ( ) { return this . _routerRoot . _route }
560559 } ) ;
561560
562- Vue . component ( 'router-view ' , View ) ;
563- Vue . component ( 'router-link ' , Link ) ;
561+ Vue . component ( 'RouterView ' , View ) ;
562+ Vue . component ( 'RouterLink ' , Link ) ;
564563
565564 var strats = Vue . config . optionMergeStrategies ;
566565 // use the same hook merging strategy for route hooks
@@ -1070,7 +1069,6 @@ function pathToRegexp (path, keys, options) {
10701069
10711070 return stringToRegexp ( /** @type {string } */ ( path ) , /** @type {!Array } */ ( keys ) , options )
10721071}
1073-
10741072pathToRegexp_1 . parse = parse_1 ;
10751073pathToRegexp_1 . compile = compile_1 ;
10761074pathToRegexp_1 . tokensToFunction = tokensToFunction_1 ;
@@ -1266,7 +1264,6 @@ function normalizePath (path, parent, strict) {
12661264
12671265/* */
12681266
1269-
12701267function normalizeLocation (
12711268 raw ,
12721269 current ,
@@ -1281,9 +1278,9 @@ function normalizeLocation (
12811278
12821279 // relative params
12831280 if ( ! next . path && next . params && current ) {
1284- next = assign ( { } , next ) ;
1281+ next = extend ( { } , next ) ;
12851282 next . _normalized = true ;
1286- var params = assign ( assign ( { } , current . params ) , next . params ) ;
1283+ var params = extend ( extend ( { } , current . params ) , next . params ) ;
12871284 if ( current . name ) {
12881285 next . name = current . name ;
12891286 next . params = params ;
@@ -1321,16 +1318,10 @@ function normalizeLocation (
13211318 }
13221319}
13231320
1324- function assign ( a , b ) {
1325- for ( var key in b ) {
1326- a [ key ] = b [ key ] ;
1327- }
1328- return a
1329- }
1330-
13311321/* */
13321322
13331323
1324+
13341325function createMatcher (
13351326 routes ,
13361327 router
@@ -1398,8 +1389,8 @@ function createMatcher (
13981389 ) {
13991390 var originalRedirect = record . redirect ;
14001391 var redirect = typeof originalRedirect === 'function'
1401- ? originalRedirect ( createRoute ( record , location , null , router ) )
1402- : originalRedirect ;
1392+ ? originalRedirect ( createRoute ( record , location , null , router ) )
1393+ : originalRedirect ;
14031394
14041395 if ( typeof redirect === 'string' ) {
14051396 redirect = { path : redirect } ;
@@ -1513,7 +1504,8 @@ function matchRoute (
15131504 var key = regex . keys [ i - 1 ] ;
15141505 var val = typeof m [ i ] === 'string' ? decodeURIComponent ( m [ i ] ) : m [ i ] ;
15151506 if ( key ) {
1516- params [ key . name ] = val ;
1507+ // Fix #1994: using * with props: true generates a param named 0
1508+ params [ key . name || 'pathMatch' ] = val ;
15171509 }
15181510 }
15191511
@@ -1526,12 +1518,12 @@ function resolveRecordPath (path, record) {
15261518
15271519/* */
15281520
1529-
15301521var positionStore = Object . create ( null ) ;
15311522
15321523function setupScroll ( ) {
15331524 // Fix for #1585 for Firefox
1534- window . history . replaceState ( { key : getStateKey ( ) } , '' ) ;
1525+ // Fix for #2195 Add optional third attribute to workaround a bug in safari https://bugs.webkit.org/show_bug.cgi?id=182678
1526+ window . history . replaceState ( { key : getStateKey ( ) } , '' , window . location . href . replace ( window . location . origin , '' ) ) ;
15351527 window . addEventListener ( 'popstate' , function ( e ) {
15361528 saveScrollPosition ( ) ;
15371529 if ( e . state && e . state . key ) {
@@ -1562,7 +1554,7 @@ function handleScroll (
15621554 // wait until re-render finishes before scrolling
15631555 router . app . $nextTick ( function ( ) {
15641556 var position = getScrollPosition ( ) ;
1565- var shouldScroll = behavior ( to , from , isPop ? position : null ) ;
1557+ var shouldScroll = behavior . call ( router , to , from , isPop ? position : null ) ;
15661558
15671559 if ( ! shouldScroll ) {
15681560 return
@@ -2124,7 +2116,10 @@ function poll (
21242116 key ,
21252117 isValid
21262118) {
2127- if ( instances [ key ] ) {
2119+ if (
2120+ instances [ key ] &&
2121+ ! instances [ key ] . _isBeingDestroyed // do not reuse being destroyed instance
2122+ ) {
21282123 cb ( instances [ key ] ) ;
21292124 } else if ( isValid ( ) ) {
21302125 setTimeout ( function ( ) {
@@ -2135,16 +2130,16 @@ function poll (
21352130
21362131/* */
21372132
2138-
21392133var HTML5History = ( function ( History$$1 ) {
21402134 function HTML5History ( router , base ) {
21412135 var this$1 = this ;
21422136
21432137 History$$1 . call ( this , router , base ) ;
21442138
21452139 var expectScroll = router . options . scrollBehavior ;
2140+ var supportsScroll = supportsPushState && expectScroll ;
21462141
2147- if ( expectScroll ) {
2142+ if ( supportsScroll ) {
21482143 setupScroll ( ) ;
21492144 }
21502145
@@ -2160,7 +2155,7 @@ var HTML5History = (function (History$$1) {
21602155 }
21612156
21622157 this$1 . transitionTo ( location , function ( route ) {
2163- if ( expectScroll ) {
2158+ if ( supportsScroll ) {
21642159 handleScroll ( router , route , current , true ) ;
21652160 }
21662161 } ) ;
@@ -2214,7 +2209,7 @@ var HTML5History = (function (History$$1) {
22142209} ( History ) ) ;
22152210
22162211function getLocation ( base ) {
2217- var path = window . location . pathname ;
2212+ var path = decodeURI ( window . location . pathname ) ;
22182213 if ( base && path . indexOf ( base ) === 0 ) {
22192214 path = path . slice ( base . length ) ;
22202215 }
@@ -2223,7 +2218,6 @@ function getLocation (base) {
22232218
22242219/* */
22252220
2226-
22272221var HashHistory = ( function ( History$$1 ) {
22282222 function HashHistory ( router , base , fallback ) {
22292223 History$$1 . call ( this , router , base ) ;
@@ -2333,7 +2327,7 @@ function getHash () {
23332327 // consistent across browsers - Firefox will pre-decode it!
23342328 var href = window . location . href ;
23352329 var index = href . indexOf ( '#' ) ;
2336- return index === - 1 ? '' : href . slice ( index + 1 )
2330+ return index === - 1 ? '' : decodeURI ( href . slice ( index + 1 ) )
23372331}
23382332
23392333function getUrl ( path ) {
@@ -2361,7 +2355,6 @@ function replaceHash (path) {
23612355
23622356/* */
23632357
2364-
23652358var AbstractHistory = ( function ( History$$1 ) {
23662359 function AbstractHistory ( router , base ) {
23672360 History$$1 . call ( this , router , base ) ;
@@ -2420,6 +2413,8 @@ var AbstractHistory = (function (History$$1) {
24202413
24212414/* */
24222415
2416+
2417+
24232418var VueRouter = function VueRouter ( options ) {
24242419 if ( options === void 0 ) options = { } ;
24252420
@@ -2616,7 +2611,7 @@ function createHref (base, fullPath, mode) {
26162611}
26172612
26182613VueRouter . install = install ;
2619- VueRouter . version = '3.0.1 ' ;
2614+ VueRouter . version = '3.0.2 ' ;
26202615
26212616if ( inBrowser && window . Vue ) {
26222617 window . Vue . use ( VueRouter ) ;
0 commit comments