Skip to content

Commit 152e5f0

Browse files
kfuledead-claudia
authored andcommitted
router: removes unnecessary hashchange-related code from the router, fixes #2778
Code that sets `fireAsync` to null and uses `hashchange` when `pushState` is not supported was removed in v2.2.0. However, some of that code and comments remained.
1 parent 2eabe5d commit 152e5f0

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

api/router.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ module.exports = function($window, mountRedraw) {
4444
},
4545
onremove: function() {
4646
$window.removeEventListener("popstate", fireAsync, false)
47-
$window.removeEventListener("hashchange", resolveRoute, false)
4847
},
4948
view: function() {
5049
if (!state || sentinel === currentResolver) return
@@ -129,10 +128,6 @@ module.exports = function($window, mountRedraw) {
129128
}
130129
}
131130

132-
// Set it unconditionally so `m.route.set` and `m.route.Link` both work,
133-
// even if neither `pushState` nor `hashchange` are supported. It's
134-
// cleared if `hashchange` is used, since that makes it automatically
135-
// async.
136131
function fireAsync() {
137132
if (!scheduled) {
138133
scheduled = true
@@ -180,11 +175,7 @@ module.exports = function($window, mountRedraw) {
180175
}
181176
}
182177

183-
if (typeof $window.history.pushState === "function") {
184-
$window.addEventListener("popstate", fireAsync, false)
185-
} else if (route.prefix[0] === "#") {
186-
$window.addEventListener("hashchange", resolveRoute, false)
187-
}
178+
$window.addEventListener("popstate", fireAsync, false)
188179

189180
ready = true
190181
mountRedraw.mount(root, RouterRoot)

0 commit comments

Comments
 (0)