提交 670d9a8b 编写于 作者: M Mike Greiling

ensure lineNumbers method always returns an array with two integers

上级 324fb743
...@@ -33,7 +33,6 @@ class Diff { ...@@ -33,7 +33,6 @@ class Diff {
handleClickUnfold(e) { handleClickUnfold(e) {
const $target = $(e.target); const $target = $(e.target);
// current babel config relies on iterators implementation, so we cannot simply do:
const [oldLineNumber, newLineNumber] = this.lineNumbers($target.parent()); const [oldLineNumber, newLineNumber] = this.lineNumbers($target.parent());
const offset = newLineNumber - oldLineNumber; const offset = newLineNumber - oldLineNumber;
const bottom = $target.hasClass('js-unfold-bottom'); const bottom = $target.hasClass('js-unfold-bottom');
...@@ -102,10 +101,11 @@ class Diff { ...@@ -102,10 +101,11 @@ class Diff {
} }
lineNumbers(line) { lineNumbers(line) {
if (!line.children().length) { const children = line.find('.diff-line-num').toArray();
if (children.length !== 2) {
return [0, 0]; 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() { highlightSelectedLine() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册