From: Bartosz Dziewoński Date: Fri, 29 Aug 2014 15:45:48 +0000 (+0200) Subject: mediawiki.action.view.redirect: Work around a IE 10+ HTML5 history API bug X-Git-Tag: 1.31.0-rc.0~14232 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/Boston?a=commitdiff_plain;h=03a4f88a22f92e59cde998245b75663427bf8266;p=lhc%2Fweb%2Fwiklou.git 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:
Beginning of page
First section
Second section (should always scroll to here)
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 --- diff --git a/resources/src/mediawiki.action/mediawiki.action.view.redirect.js b/resources/src/mediawiki.action/mediawiki.action.view.redirect.js index c87ff7cbc6..b9aa137e31 100644 --- a/resources/src/mediawiki.action/mediawiki.action.view.redirect.js +++ b/resources/src/mediawiki.action/mediawiki.action.view.redirect.js @@ -38,6 +38,11 @@ // This will also cause the browser to scroll to given fragment history.replaceState( /*data=*/ history.state, /*title=*/ document.title, /*url=*/ canonical ); + // …except for IE 10 and 11. Prod it with a location.hash change. + if ( shouldChangeFragment && profile.name === 'msie' && profile.versionNumber >= 10 ) { + location.hash = fragment; + } + } else if ( shouldChangeFragment ) { if ( profile.layout === 'webkit' && profile.layoutVersion < 420 ) { // Released Safari w/ WebKit 418.9.1 messes up horribly