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
This commit is contained in:
Brion Vibber 2015-07-02 04:38:52 -07:00 committed by Gergő Tisza
parent 7b064306d8
commit e77df57615

View file

@ -469,7 +469,12 @@
hash = window.location.href.replace( /#.*$/, '' ); 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 { } else {
// Since we voluntarily changed the hash, we don't want MMVB.hash (which will trigger on hashchange event) to treat it // Since we voluntarily changed the hash, we don't want MMVB.hash (which will trigger on hashchange event) to treat it
this.skipNextHashHandling = true; this.skipNextHashHandling = true;