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

Fix a JS issue when the anchor element on a page has no container

Summary: See D21213. If there's no matching element, `findAbove()` throws. Handle these cases correctly.

Test Plan: Visited `#toc` on a revision, no longer saw a JS error.

Differential Revision: https://secure.phabricator.com/D21222
This commit is contained in:
epriestley 2020-05-04 15:48:47 -07:00
parent 6430d6d638
commit 6b69102990
2 changed files with 18 additions and 10 deletions

View file

@ -10,7 +10,7 @@ return array(
'conpherence.pkg.css' => '0e3cf785', 'conpherence.pkg.css' => '0e3cf785',
'conpherence.pkg.js' => '020aebcf', 'conpherence.pkg.js' => '020aebcf',
'core.pkg.css' => '1b80c45d', 'core.pkg.css' => '1b80c45d',
'core.pkg.js' => '632fb8f5', 'core.pkg.js' => '1e667bcb',
'dark-console.pkg.js' => '187792c2', 'dark-console.pkg.js' => '187792c2',
'differential.pkg.css' => '2d70b7b9', 'differential.pkg.css' => '2d70b7b9',
'differential.pkg.js' => '22ec6f26', 'differential.pkg.js' => '22ec6f26',
@ -508,7 +508,7 @@ return array(
'rsrc/js/core/behavior-tokenizer.js' => '3b4899b0', 'rsrc/js/core/behavior-tokenizer.js' => '3b4899b0',
'rsrc/js/core/behavior-tooltip.js' => '73ecc1f8', 'rsrc/js/core/behavior-tooltip.js' => '73ecc1f8',
'rsrc/js/core/behavior-user-menu.js' => '60cd9241', 'rsrc/js/core/behavior-user-menu.js' => '60cd9241',
'rsrc/js/core/behavior-watch-anchor.js' => 'e55a1db5', 'rsrc/js/core/behavior-watch-anchor.js' => 'a77e2cbd',
'rsrc/js/core/behavior-workflow.js' => '9623adc1', 'rsrc/js/core/behavior-workflow.js' => '9623adc1',
'rsrc/js/core/darkconsole/DarkLog.js' => '3b869402', 'rsrc/js/core/darkconsole/DarkLog.js' => '3b869402',
'rsrc/js/core/darkconsole/DarkMessage.js' => '26cd4b73', 'rsrc/js/core/darkconsole/DarkMessage.js' => '26cd4b73',
@ -658,7 +658,7 @@ return array(
'javelin-behavior-phabricator-tooltips' => '73ecc1f8', 'javelin-behavior-phabricator-tooltips' => '73ecc1f8',
'javelin-behavior-phabricator-transaction-comment-form' => '2bdadf1a', 'javelin-behavior-phabricator-transaction-comment-form' => '2bdadf1a',
'javelin-behavior-phabricator-transaction-list' => '9cec214e', 'javelin-behavior-phabricator-transaction-list' => '9cec214e',
'javelin-behavior-phabricator-watch-anchor' => 'e55a1db5', 'javelin-behavior-phabricator-watch-anchor' => 'a77e2cbd',
'javelin-behavior-pholio-mock-edit' => '3eed1f2b', 'javelin-behavior-pholio-mock-edit' => '3eed1f2b',
'javelin-behavior-pholio-mock-view' => '5aa1544e', 'javelin-behavior-pholio-mock-view' => '5aa1544e',
'javelin-behavior-phui-dropdown-menu' => '5cf0501a', 'javelin-behavior-phui-dropdown-menu' => '5cf0501a',
@ -1874,6 +1874,12 @@ return array(
'javelin-install', 'javelin-install',
'javelin-dom', 'javelin-dom',
), ),
'a77e2cbd' => array(
'javelin-behavior',
'javelin-stratcom',
'javelin-dom',
'javelin-vector',
),
'a8f573a9' => array( 'a8f573a9' => array(
'javelin-install', 'javelin-install',
'javelin-dom', 'javelin-dom',
@ -2122,12 +2128,6 @@ return array(
'javelin-dom', 'javelin-dom',
'phuix-dropdown-menu', 'phuix-dropdown-menu',
), ),
'e55a1db5' => array(
'javelin-behavior',
'javelin-stratcom',
'javelin-dom',
'javelin-vector',
),
'e5bdb730' => array( 'e5bdb730' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-stratcom', 'javelin-stratcom',

View file

@ -98,7 +98,15 @@ JX.behavior('phabricator-watch-anchor', function() {
// If there's an "anchor-container" parent element, we'll make the // If there's an "anchor-container" parent element, we'll make the
// display adjustment to that node instead. For example, this is used // display adjustment to that node instead. For example, this is used
// by the timeline to highlight timeline stories. // by the timeline to highlight timeline stories.
var container = JX.DOM.findAbove(node, null, 'anchor-container');
var container;
try {
container = JX.DOM.findAbove(node, null, 'anchor-container');
} catch (ex) {
// Ignore.
}
if (container) { if (container) {
display_target = container; display_target = container;
} else { } else {