summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Greiling <mike@pixelcog.com>2017-03-22 02:57:31 -0500
committerMike Greiling <mike@pixelcog.com>2017-03-23 17:52:57 -0500
commit670d9a8bb6e786910b717f76657b1d2a7c41f22d (patch)
tree832f1c4511558a2bcf6e634d0c043ae897ae77bc
parent324fb743043e61a400e21764e0496b70f3a3f8ed (diff)
downloadgitlab-ce-670d9a8bb6e786910b717f76657b1d2a7c41f22d.tar.gz
ensure lineNumbers method always returns an array with two integers
-rw-r--r--app/assets/javascripts/diff.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/app/assets/javascripts/diff.js b/app/assets/javascripts/diff.js
index dca12bbcf10..88180149715 100644
--- a/app/assets/javascripts/diff.js
+++ b/app/assets/javascripts/diff.js
@@ -33,7 +33,6 @@ class Diff {
handleClickUnfold(e) {
const $target = $(e.target);
- // current babel config relies on iterators implementation, so we cannot simply do:
const [oldLineNumber, newLineNumber] = this.lineNumbers($target.parent());
const offset = newLineNumber - oldLineNumber;
const bottom = $target.hasClass('js-unfold-bottom');
@@ -102,10 +101,11 @@ class Diff {
}
lineNumbers(line) {
- if (!line.children().length) {
+ const children = line.find('.diff-line-num').toArray();
+ if (children.length !== 2) {
return [0, 0];
}
- return line.find('.diff-line-num').map((i, elm) => parseInt($(elm).data('linenumber'), 10));
+ return children.map(elm => parseInt($(elm).data('linenumber'), 10) || 0);
}
highlightSelectedLine() {