From dde63af1cc86c5eedc1cbe492d8c721aa59a67b5 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 17 May 2017 08:35:13 -0700 Subject: [PATCH] Fix a JS console warning when hovering over replies to ghosts on lines which no longer exist Summary: Fixes T11662. In the very obscure situation described in that task, quiet a JS console warning. The actual edit operation appears to work correctly after changes elsewhere. There aren't really any legitimate lines for us to highlight in this case so I'm just giving up rather than trying to do something approximate. Test Plan: - Wrote `long.txt`. - Created revision. - Added an inline near the bottom. - Removed most of `long.txt`. - Updated revsion. - Replied to the ghost inline. - Edited the reply to the ghost inline, worked. - Hovered the reply to the ghost inline: no line highlight, but no errors. Reviewers: chad Reviewed By: chad Maniphest Tasks: T11662 Differential Revision: https://secure.phabricator.com/D17930 --- resources/celerity/map.php | 12 ++++++------ .../js/application/diff/DiffChangesetList.js | 19 +++++++++++++++---- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 40b61fca95..e82602aa0b 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -13,7 +13,7 @@ return array( 'core.pkg.js' => '0f87a6eb', 'darkconsole.pkg.js' => '1f9a31bc', 'differential.pkg.css' => 'ea471cb0', - 'differential.pkg.js' => '58457c19', + 'differential.pkg.js' => '4a466790', 'diffusion.pkg.css' => 'b93d9b8c', 'diffusion.pkg.js' => '84c8f8fd', 'favicon.ico' => '30672e08', @@ -391,7 +391,7 @@ return array( 'rsrc/js/application/dashboard/behavior-dashboard-query-panel-select.js' => '453c5375', 'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => 'd4eecc63', 'rsrc/js/application/diff/DiffChangeset.js' => '68758d99', - 'rsrc/js/application/diff/DiffChangesetList.js' => '204e4bfc', + 'rsrc/js/application/diff/DiffChangesetList.js' => '796922e0', 'rsrc/js/application/diff/DiffInline.js' => '1afe9760', 'rsrc/js/application/diff/behavior-preview-link.js' => '051c7832', 'rsrc/js/application/differential/behavior-comment-preview.js' => 'b064af76', @@ -778,7 +778,7 @@ return array( 'phabricator-darkmessage' => 'c48cccdd', 'phabricator-dashboard-css' => 'fe5b1869', 'phabricator-diff-changeset' => '68758d99', - 'phabricator-diff-changeset-list' => '204e4bfc', + 'phabricator-diff-changeset-list' => '796922e0', 'phabricator-diff-inline' => '1afe9760', 'phabricator-drag-and-drop-file-upload' => '58dea2fa', 'phabricator-draggable-list' => 'bea6e7f4', @@ -1066,9 +1066,6 @@ return array( 'javelin-install', 'javelin-dom', ), - '204e4bfc' => array( - 'javelin-install', - ), '21df4ff5' => array( 'javelin-install', 'javelin-workboard-card', @@ -1496,6 +1493,9 @@ return array( 'javelin-behavior', 'javelin-quicksand', ), + '796922e0' => array( + 'javelin-install', + ), '7a68dda3' => array( 'owners-path-editor', 'javelin-behavior', diff --git a/webroot/rsrc/js/application/diff/DiffChangesetList.js b/webroot/rsrc/js/application/diff/DiffChangesetList.js index e57ebc1674..6e3853a9d1 100644 --- a/webroot/rsrc/js/application/diff/DiffChangesetList.js +++ b/webroot/rsrc/js/application/diff/DiffChangesetList.js @@ -968,11 +968,22 @@ JX.install('DiffChangesetList', { var number = inline.getLineNumber(); var length = inline.getLineLength(); - var origin = JX.$(prefix + number); - var target = JX.$(prefix + (number + length)); + try { + var origin = JX.$(prefix + number); + var target = JX.$(prefix + (number + length)); - this._hoverOrigin = origin; - this._hoverTarget = target; + this._hoverOrigin = origin; + this._hoverTarget = target; + } catch (error) { + // There may not be any nodes present in the document. A case where + // this occurs is when you reply to a ghost inline which was made + // on lines near the bottom of "long.txt" in an earlier diff, and + // the file was later shortened so those lines no longer exist. For + // more details, see T11662. + + this._hoverOrigin = null; + this._hoverTarget = null; + } } else { this._hoverOrigin = null; this._hoverTarget = null;