We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 23d87d8 commit c0d3376Copy full SHA for c0d3376
src/util/push-state.js
@@ -3,6 +3,7 @@
3
import { inBrowser } from './dom'
4
import { saveScrollPosition } from './scroll'
5
import { genStateKey, setStateKey, getStateKey } from './state-key'
6
+import { extend } from './misc'
7
8
export const supportsPushState =
9
inBrowser &&
@@ -28,7 +29,10 @@ export function pushState (url?: string, replace?: boolean) {
28
29
const history = window.history
30
try {
31
if (replace) {
- 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)
36
} else {
37
history.pushState({ key: setStateKey(genStateKey()) }, '', url)
38
}
0 commit comments