Commit fb2d448 1 parent 3a33ed9 commit fb2d448 Copy full SHA for fb2d448
File tree 1 file changed +17
-0
lines changed
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,9 @@ class AppRouter {
39
39
constructor ( ) {
40
40
document . addEventListener ( 'viewshow' , ( ) => this . onViewShow ( ) ) ;
41
41
42
+ this . lastPath = history . location . pathname + history . location . search ;
43
+ this . listen ( ) ;
44
+
42
45
// TODO: Can this baseRoute logic be simplified?
43
46
this . baseRoute = window . location . href . split ( '?' ) [ 0 ] . replace ( this . #getRequestFile( ) , '' ) ;
44
47
// support hashbang
@@ -100,6 +103,20 @@ class AppRouter {
100
103
return this . promiseShow ;
101
104
}
102
105
106
+ listen ( ) {
107
+ history . listen ( ( { location } ) => {
108
+ const normalizedPath = location . pathname . replace ( / ^ ! / , '' ) ;
109
+ const fullPath = normalizedPath + location . search ;
110
+
111
+ if ( fullPath === this . lastPath ) {
112
+ console . debug ( '[appRouter] path did not change, resolving promise' ) ;
113
+ this . onViewShow ( ) ;
114
+ }
115
+
116
+ this . lastPath = fullPath ;
117
+ } ) ;
118
+ }
119
+
103
120
baseUrl ( ) {
104
121
return this . baseRoute ;
105
122
}
You can’t perform that action at this time.
0 commit comments