From fbe139e9c057c597ccae84194b9c28967e60e812 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Fri, 19 Mar 2010 20:45:29 +0000 Subject: [PATCH] Future-proof redirection to fragments in Gecko Previously, in Gecko we wouldn't set document.location.hash at all until the page loaded. This means that if they fix their bug, so setting document.location.hash to an id that doesn't yet exist (but will before load is finished) works properly, we still would only jump to the right place onload, not ASAP. Now we'll jump to the right place ASAP, and then jump again on load, which is better (although still annoying if the gap ends up being perceptible). Too bad I can't think of a way to feature-test this. --- RELEASE-NOTES | 2 ++ skins/common/wikibits.js | 25 +++++++++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 1045b40c76..d6e7564e57 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -32,6 +32,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN options * $wgAllowUserCssPrefs option allows disabling CSS-based preferences; which can improve page loading speed. +* Future-proof redirection to fragments in Gecko, so things work a little nicer + if they fix . === Bug fixes in 1.17 === * (bug 17560) Half-broken deletion moved image files to deletion archive without diff --git a/skins/common/wikibits.js b/skins/common/wikibits.js index 7cee7614d3..2a75478ab5 100644 --- a/skins/common/wikibits.js +++ b/skins/common/wikibits.js @@ -497,16 +497,21 @@ function redirectToFragment( fragment ) { return; } } - if ( is_gecko ) { - // Mozilla needs to wait until after load, otherwise the window doesn't scroll - addOnloadHook(function() { - if ( window.location.hash == '' ) { - window.location.hash = fragment; - } - }); - } else { - if ( window.location.hash == '' ) { - window.location.hash = fragment; + if ( window.location.hash == '' ) { + window.location.hash = fragment; + + // Mozilla needs to wait until after load, otherwise the window doesn't + // scroll. See . + // There's no obvious way to detect this programmatically, so we use + // version-testing. If Firefox fixes the bug, they'll jump twice, but + // better twice than not at all, so make the fix hit future versions as + // well. + if ( is_gecko ) { + addOnloadHook(function() { + if ( window.location.hash == fragment ) { + window.location.hash = fragment; + } + }); } } } -- 2.20.1