File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change 33import { inBrowser } from './dom'
44import { saveScrollPosition } from './scroll'
55import { genStateKey , setStateKey , getStateKey } from './state-key'
6+ import { extend } from './misc'
67
78export const supportsPushState =
89 inBrowser &&
@@ -28,7 +29,10 @@ export function pushState (url?: string, replace?: boolean) {
2829 const history = window . history
2930 try {
3031 if ( replace ) {
31- history . replaceState ( { key : getStateKey ( ) } , '' , url )
32+ // preserve existing history state as it could be overriden by the user
33+ const stateCopy = extend ( { } , history . state )
34+ stateCopy . key = getStateKey ( )
35+ history . replaceState ( stateCopy , '' , url )
3236 } else {
3337 history. pushState ( { key : setStateKey ( genStateKey ( ) ) } , '' , url )
3438 }
You can’t perform that action at this time.
0 commit comments