Skip to content

Commit 9546370

Browse files
committed
Make Router only listen for hashchange in IE
Reference: elm-lang/navigation@21cae6c
1 parent 020ee20 commit 9546370

File tree

1 file changed

+8
-1
lines changed
  • extra/src/main/scala/japgolly/scalajs/react/extra/router

1 file changed

+8
-1
lines changed

extra/src/main/scala/japgolly/scalajs/react/extra/router/Router.scala

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,15 @@ object Router {
2424
.componentDidUpdate (i => cfg.postRenderFn(Some(i.prevState.page), i.currentState.page))
2525
.configure(
2626
EventListener.install("popstate", _ => lgc.ctl.refresh, _ => dom.window),
27-
EventListener.install("hashchange", _ => lgc.ctl.refresh, _ => dom.window),
2827
Listenable.listenToUnit(_ => lgc, $ => lgc.syncToWindowUrl.flatMap($.setState(_))))
28+
.configure(
29+
if (isIE11())
30+
EventListener.install("hashchange", _ => lgc.ctl.refresh, _ => dom.window)
31+
else
32+
identityFn)
33+
34+
private def isIE11(): Boolean =
35+
dom.window.navigator.userAgent.indexOf("Trident") != -1
2936

3037
def componentAndLogic[Page](baseUrl: BaseUrl, cfg: RouterConfig[Page]): (Router[Page], RouterLogic[Page]) = {
3138
val l = new RouterLogic(baseUrl, cfg)

0 commit comments

Comments
 (0)