Skip to content

Commit a95b95f

Browse files
committed
get rid of flow hack
1 parent 83418bc commit a95b95f

File tree

3 files changed

+11
-20
lines changed

3 files changed

+11
-20
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"eslint-plugin-html": "^1.5.2",
5050
"express": "^4.14.0",
5151
"express-urlrewrite": "^1.2.0",
52-
"flow-bin": "^0.32.0",
52+
"flow-bin": "^0.33.0",
5353
"gitbook-plugin-edit-link": "^2.0.2",
5454
"gitbook-plugin-github": "^2.0.0",
5555
"jasmine": "2.4.1",

src/history/base.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,6 @@ export class History {
108108
hook && hook(route, prev)
109109
})
110110
}
111-
112-
/**
113-
* Dummy method to make flow happy...
114-
* otherwise it won't let me call `this.history.onHashChange`
115-
* inside a `switch case`...
116-
* Advices on how to remove this method are much appreciated.
117-
*/
118-
onHashChange () {}
119111
}
120112

121113
function normalizeBase (base: ?string): string {

src/index.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,19 @@ export default class VueRouter {
6565

6666
this.app = app
6767

68-
switch (this.mode) {
69-
case 'history':
70-
this.history.transitionTo(getLocation(this.history.base))
71-
break
72-
case 'hash':
73-
this.history.transitionTo(getHash(), () => {
74-
window.addEventListener('hashchange', () => {
75-
this.history.onHashChange()
76-
})
68+
const history = this.history
69+
70+
if (history instanceof HTML5History) {
71+
history.transitionTo(getLocation(history.base))
72+
} else if (history instanceof HashHistory) {
73+
history.transitionTo(getHash(), () => {
74+
window.addEventListener('hashchange', () => {
75+
history.onHashChange()
7776
})
78-
break
77+
})
7978
}
8079

81-
this.history.listen(route => {
80+
history.listen(route => {
8281
this.app._route = route
8382
})
8483
}

0 commit comments

Comments
 (0)