11/*!
22 * vue-router v3.0.7
3- * (c) 2019 Evan You
3+ * (c) 2022 Evan You
44 * @license MIT
55 */
66( function ( global , factory ) {
@@ -2454,7 +2454,11 @@ var HashHistory = /*@__PURE__*/(function (History$$1) {
24542454 if ( ! ensureSlash ( ) ) {
24552455 return
24562456 }
2457- this$1 . transitionTo ( getHash ( ) , function ( route ) {
2457+ var locations = [ getHash ( ) ] ;
2458+ if ( window . history && window . history . state && typeof window . history . state . state === 'object' ) {
2459+ locations = window . history . state . state ;
2460+ }
2461+ this$1 . transitionTo ( locations , function ( route ) {
24582462 if ( supportsScroll ) {
24592463 handleScroll ( this$1 . router , route , current , true ) ;
24602464 }
@@ -2465,38 +2469,52 @@ var HashHistory = /*@__PURE__*/(function (History$$1) {
24652469 } ) ;
24662470 } ;
24672471
2468- HashHistory . prototype . push = function push ( location , onComplete , onAbort ) {
2472+ HashHistory . prototype . navigateAllLayers = function navigateAllLayers ( locations , push , onComplete , onAbort ) {
24692473 var this$1 = this ;
24702474
24712475 var ref = this ;
24722476 var fromRoute = ref . current ;
2473- this . transitionTo ( location , function ( route ) {
2477+ this . transitionTo ( locations , function ( routes ) {
2478+ var route = this$1 . current [ this$1 . current . length - 1 ] ;
24742479 pushHash ( route . fullPath ) ;
24752480 handleScroll ( this$1 . router , route , fromRoute , false ) ;
24762481 onComplete && onComplete ( route ) ;
24772482 } , onAbort ) ;
24782483 } ;
24792484
2480- HashHistory . prototype . replace = function replace ( location , onComplete , onAbort ) {
2481- var this$1 = this ;
2485+ HashHistory . prototype . navigateLastLayer = function navigateLastLayer ( location , push , onComplete , onAbort ) {
2486+ var locations = this . current . slice ( 0 , - 1 ) . map ( function ( r ) { return r . fullPath ; } ) . concat ( [ location ]
2487+ ) ;
2488+ this . navigateAllLayers ( locations , push , onComplete , onAbort ) ;
2489+ } ;
24822490
2483- var ref = this ;
2484- var fromRoute = ref . current ;
2485- this . transitionTo ( location , function ( route ) {
2486- replaceHash ( route . fullPath ) ;
2487- handleScroll ( this$1 . router , route , fromRoute , false ) ;
2488- onComplete && onComplete ( route ) ;
2489- } , onAbort ) ;
2491+ HashHistory . prototype . navigateLayer = function navigateLayer ( layer , location , push , onComplete , onAbort ) {
2492+ var locations = this . current . slice ( 0 , layer ) . map ( function ( r ) { return r . fullPath ; } ) . concat ( [ location ] ,
2493+ this . current . slice ( layer + 1 ) . map ( function ( r ) { return r . fullPath ; } )
2494+ ) ;
2495+ this . navigateAllLayers ( locations , push , onComplete , onAbort ) ;
2496+ } ;
2497+
2498+ HashHistory . prototype . navigateAddLayer = function navigateAddLayer ( location , push , onComplete , onAbort ) {
2499+ var locations = this . current . map ( function ( r ) { return r . fullPath ; } ) . concat ( [ location ]
2500+ ) ;
2501+ this . navigateAllLayers ( locations , push , onComplete , onAbort ) ;
2502+ } ;
2503+
2504+ HashHistory . prototype . navigateRemoveLayer = function navigateRemoveLayer ( location , push , onComplete , onAbort ) {
2505+ var locations = this . current . slice ( 0 , - 1 ) . map ( function ( r ) { return r . fullPath ; } ) ;
2506+ this . navigateAllLayers ( locations , push , onComplete , onAbort ) ;
24902507 } ;
24912508
24922509 HashHistory . prototype . go = function go ( n ) {
24932510 window . history . go ( n ) ;
24942511 } ;
24952512
24962513 HashHistory . prototype . ensureURL = function ensureURL ( push ) {
2497- var current = this . current . fullPath ;
2498- if ( getHash ( ) !== current ) {
2499- push ? pushHash ( current ) : replaceHash ( current ) ;
2514+ var route = this . current [ this . current . length - 1 ] ;
2515+ if ( getHash ( ) !== route . fullPath ) {
2516+ var path = cleanPath ( this . base + route . fullPath ) ;
2517+ pushState ( path , this . current . map ( function ( r ) { return r . fullPath ; } ) , ! push ) ;
25002518 }
25012519 } ;
25022520
@@ -2742,7 +2760,7 @@ VueRouter.prototype.init = function init (app /* Vue component instance */) {
27422760 history . setupListeners ( ) ;
27432761 } ;
27442762 history . transitionTo (
2745- history . getCurrentLocation ( ) ,
2763+ [ history . getCurrentLocation ( ) ] ,
27462764 setupHashListener ,
27472765 setupHashListener
27482766 ) ;
0 commit comments