jenkins-bot has submitted this change and it was merged. Change subject: mediawiki.action.view.redirect: Explicitly scroll to element in hash ......................................................................
mediawiki.action.view.redirect: Explicitly scroll to element in hash Specification of replaceState doesn't state whether the browser should scroll to the element matching the fragment [1]. It only determines how to alter the history stack. (The fact it doesn't impact UI is sometimes a desired behaviour [2)] As a result force a scroll to the element. Harmless if element is already present. [1] http://www.w3.org/TR/2011/WD-html5-20110113/history.html#the-history-interface [2] http://lea.verou.me/2011/05/change-url-hash-without-page-jump/ Bug: T110501 Change-Id: I7440f7a6a6dd20d984da1834007d581324fb96f4 --- M resources/src/mediawiki.action/mediawiki.action.view.redirect.js 1 file changed, 9 insertions(+), 6 deletions(-) Approvals: Krinkle: Looks good to me, approved Jdlrobson: Looks good to me, but someone else must approve jenkins-bot: Verified diff --git a/resources/src/mediawiki.action/mediawiki.action.view.redirect.js b/resources/src/mediawiki.action/mediawiki.action.view.redirect.js index e66d8f6..29a5a79 100644 --- a/resources/src/mediawiki.action/mediawiki.action.view.redirect.js +++ b/resources/src/mediawiki.action/mediawiki.action.view.redirect.js @@ -9,7 +9,7 @@ var profile = $.client.profile(), canonical = mw.config.get( 'wgInternalRedirectTargetUrl' ), fragment = null, - shouldChangeFragment, index; + node, shouldChangeFragment, index; index = canonical.indexOf( '#' ); if ( index !== -1 ) { @@ -27,12 +27,15 @@ canonical += location.hash; } - // This will also cause the browser to scroll to given fragment + // Note that this will update the hash in a modern browser, retaining back behaviour 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; + if ( shouldChangeFragment ) { + // Specification for history.replaceState() doesn't require browser to scroll, + // so scroll to be sure (see also T110501). Support for IE9 and IE10. + node = document.getElementById( fragment.slice( 1 ) ); + if ( node ) { + node.scrollIntoView(); + } } } else if ( shouldChangeFragment ) { -- To view, visit https://gerrit.wikimedia.org/r/259190 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I7440f7a6a6dd20d984da1834007d581324fb96f4 Gerrit-PatchSet: 6 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Jdlrobson <[email protected]> Gerrit-Reviewer: Edokter <[email protected]> Gerrit-Reviewer: Jack Phoenix <[email protected]> Gerrit-Reviewer: Jdlrobson <[email protected]> Gerrit-Reviewer: Krinkle <[email protected]> Gerrit-Reviewer: Ori.livneh <[email protected]> Gerrit-Reviewer: Phuedx <[email protected]> Gerrit-Reviewer: TheDJ <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
