Add undefined check throughout app

Removes both "no execute _computeDiffURL before patchNum is knwon"
and "gr-linked-text with null config" tests.

This is due to behaviour changes in Polymer2 which means functions are
always called regardless if one of the params is undefined.

Change-Id: I4bdbe03f9dc46d03a8d0997055271327f0c2a2ea
This commit is contained in:
Paladox none
2019-10-06 15:47:21 +00:00
parent 097fc86bde
commit 1e3853d593
19 changed files with 82 additions and 50 deletions

View File

@@ -891,6 +891,7 @@
* than SYNTAX_MAX_LINE_LENGTH.
*/
_anyLineTooLong(diff) {
if (!diff) return false;
return diff.content.some(section => {
const lines = section.ab ?
section.ab :

View File

@@ -265,7 +265,8 @@
_getFiles(changeNum, patchRangeRecord) {
// Polymer 2: check for undefined
if ([changeNum, patchRangeRecord].some(arg => arg === undefined)) {
if ([changeNum, patchRangeRecord, patchRangeRecord.base]
.some(arg => arg === undefined)) {
return;
}
@@ -745,6 +746,9 @@
},
_getDiffUrl(change, patchRange, path) {
if ([change, patchRange, path].some(arg => arg === undefined)) {
return '';
}
return Gerrit.Nav.getUrlForDiff(change, path, patchRange.patchNum,
patchRange.basePatchNum);
},
@@ -783,6 +787,9 @@
},
_getChangePath(change, patchRange, revisions) {
if ([change, patchRange].some(arg => arg === undefined)) {
return '';
}
const range = this._getChangeUrlRange(patchRange, revisions);
return Gerrit.Nav.getUrlForChange(change, range.patchNum,
range.basePatchNum);

View File

@@ -967,6 +967,7 @@
* @return {number}
*/
getDiffLength(diff) {
if (!diff) return 0;
return diff.content.reduce((sum, sec) => {
if (sec.hasOwnProperty('ab')) {
return sum + sec.ab.length;