Skip to content

Commit a95795c

Browse files
committed
ensure hashchange listener is always created (fix #853)
1 parent 965bfcf commit a95795c

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/history/hash.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import { cleanPath } from '../util/path'
88
export class HashHistory extends History {
99
constructor (router: VueRouter, base: ?string, fallback: boolean) {
1010
super(router, base)
11+
window.addEventListener('hashchange', () => {
12+
this.onHashChange()
13+
})
1114

1215
// check history fallback deeplinking
1316
if (fallback && this.checkFallback()) {

src/index.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,7 @@ export default class VueRouter {
7272
if (history instanceof HTML5History) {
7373
history.transitionTo(getLocation(history.base))
7474
} else if (history instanceof HashHistory) {
75-
history.transitionTo(getHash(), () => {
76-
window.addEventListener('hashchange', () => {
77-
history.onHashChange()
78-
})
79-
})
75+
history.transitionTo(getHash())
8076
}
8177

8278
history.listen(route => {

0 commit comments

Comments
 (0)