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:
@@ -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 :
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user