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 3
3
import { inBrowser } from './dom'
4
4
import { saveScrollPosition } from './scroll'
5
5
import { genStateKey , setStateKey , getStateKey } from './state-key'
6
+ import { extend } from './misc'
6
7
7
8
export const supportsPushState =
8
9
inBrowser &&
@@ -28,7 +29,10 @@ export function pushState (url?: string, replace?: boolean) {
28
29
const history = window . history
29
30
try {
30
31
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 )
32
36
} else {
33
37
history. pushState ( { key : setStateKey ( genStateKey ( ) ) } , '' , url )
34
38
}
You can’t perform that action at this time.
0 commit comments