1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

Fix highlighting anchors on hashchange

Summary: Listener sends the event to `try_anchor` in the first argument.

Test Plan: Displayed diff, clicked on `#comment-1`, went back in history, clicked on `#summary`.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3327
This commit is contained in:
vrana 2012-08-17 15:40:30 -07:00
parent 8ee2a6f988
commit 21651c6bc6

View file

@ -27,10 +27,13 @@ JX.behavior('phabricator-watch-anchor', function() {
// In some cases, we link to an anchor but the anchor target ajaxes in
// later. If it pops in within the first few seconds, jump to it.
function try_anchor(anchor) {
function try_anchor() {
var anchor = window.location.hash.replace('#', '');
try {
// If the anchor exists, assume the browser handled the jump.
if (anchor) {
JX.$(anchor);
}
defer_highlight();
} catch (e) {
var n = 50;
@ -49,10 +52,6 @@ JX.behavior('phabricator-watch-anchor', function() {
}
JX.Stratcom.listen('hashchange', null, try_anchor);
var anchor = window.location.hash.replace('#', '');
if (anchor) {
try_anchor(anchor);
}
try_anchor();
});