File tree Expand file tree Collapse file tree 3 files changed +11
-20
lines changed Expand file tree Collapse file tree 3 files changed +11
-20
lines changed Original file line number Diff line number Diff line change 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" ,
Original file line number Diff line number Diff 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
121113function normalizeBase ( base : ?string ) : string {
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments