mediawiki.action.view.redirect: Work around a IE 10+ HTML5 history API bug
authorBartosz Dziewoński <matma.rex@gmail.com>
Fri, 29 Aug 2014 15:45:48 +0000 (17:45 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Fri, 29 Aug 2014 16:05:49 +0000 (18:05 +0200)
commit03a4f88a22f92e59cde998245b75663427bf8266
treea5920b8d50c9777eb4ce6f88b22004ba255de352
parent781007cc51cb2492e9ca867744b23bdd56e4a766
mediawiki.action.view.redirect: Work around a IE 10+ HTML5 history API bug

Internet Explorer 10 and 11 doesn't scroll the page to given fragment
when `history.replaceState` is used. Changing `location.hash` afterwards,
even though it's a no-op, results in the page scrolling properly.

Minimal broken test case:
  <style>div { height: 1000px; border: 1px solid blue; }</style>
  <script>history.replaceState( /*data=*/ history.state, /*title=*/ document.title, /*url=*/ '#second' );</script>
  <div id="start">Beginning of page</div>
  <div id="first">First section</div>
  <div id="second">Second section (should always scroll to here)</div>

JSFiddle test case:
* Works:        http://jsfiddle.net/rv9w9wr5/
* Doesn't work: http://jsfiddle.net/e6fy0mar/
* Works again:  http://jsfiddle.net/o8vc5grf/

It is also interesting to try visiting the test cases with a fragment
already in the URL. It seems that the history API in IE updates the
page's address, but doesn't update "fragment state" – the broken,
second testcase scrolls to #first in spite of displaying #second in
the address bar.

* http://fiddle.jshell.net/rv9w9wr5/show/light/#first
* http://fiddle.jshell.net/e6fy0mar/show/light/#first
* http://fiddle.jshell.net/o8vc5grf/show/light/#first

Bug: 70176
Change-Id: I19221a25a3167e94c2aa412bfdd8d0d8c57c5076
resources/src/mediawiki.action/mediawiki.action.view.redirect.js