From e77df576152caea9519b31307336db173ba0e095 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 2 Jul 2015 04:38:52 -0700 Subject: [PATCH] Workaround apparent bug in Edge's history.pushState When attempting to clear the hash state via history.pushState(), MS Edge in Windows 10 build 10159 errors out with the helpful "Unspecified Error". Catching the exception and trying again with a "#" works around the error and doesn't look any worse than the non-pushState code path -- and should have no side effects when the bug is fixed. Bug: T104381 Change-Id: I6ea4d367af64f85018b06b859ce688053a1caf0f --- resources/mmv/mmv.bootstrap.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/resources/mmv/mmv.bootstrap.js b/resources/mmv/mmv.bootstrap.js index 53059f76a..cac6af5cb 100644 --- a/resources/mmv/mmv.bootstrap.js +++ b/resources/mmv/mmv.bootstrap.js @@ -469,7 +469,12 @@ hash = window.location.href.replace( /#.*$/, '' ); } - this.browserHistory.pushState( null, title, hash ); + try { + window.history.pushState( null, title, hash ); + } catch ( ex ) { + // Workaround for Edge bug -- https://phabricator.wikimedia.org/T104381 + window.history.pushState( null, title, hash + '#' ); + } } else { // Since we voluntarily changed the hash, we don't want MMVB.hash (which will trigger on hashchange event) to treat it this.skipNextHashHandling = true;