Add undefined check for observers with multiple args
As in Polymer 2, observers will run at least one of the dependencies is defined while Polymer 1 will wait for all dependencies to be defined. This change will add an undefined check to wait until all arguments are defined for obervers with more than one arguments. Bug: Issue 10723 Change-Id: I372359b2f9eb6200f06f22c744c57e9d725d69ba
This commit is contained in:
@@ -159,6 +159,11 @@
|
||||
},
|
||||
|
||||
_computePreferences(account, preferences) {
|
||||
// Polymer 2: check for undefined
|
||||
if ([account, preferences].some(arg => arg === undefined)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.changeTableColumns = this.columnNames;
|
||||
|
||||
if (account) {
|
||||
|
||||
@@ -590,6 +590,15 @@
|
||||
|
||||
_actionsChanged(actionsChangeRecord, revisionActionsChangeRecord,
|
||||
additionalActionsChangeRecord) {
|
||||
// Polymer 2: check for undefined
|
||||
if ([
|
||||
actionsChangeRecord,
|
||||
revisionActionsChangeRecord,
|
||||
additionalActionsChangeRecord,
|
||||
].some(arg => arg === undefined)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const additionalActions = (additionalActionsChangeRecord &&
|
||||
additionalActionsChangeRecord.base) || [];
|
||||
this.hidden = this._keyCount(actionsChangeRecord) === 0 &&
|
||||
@@ -620,6 +629,15 @@
|
||||
|
||||
_editStatusChanged(editMode, editPatchsetLoaded,
|
||||
editBasedOnCurrentPatchSet, disableEdit) {
|
||||
// Polymer 2: check for undefined
|
||||
if ([
|
||||
editMode,
|
||||
editBasedOnCurrentPatchSet,
|
||||
disableEdit,
|
||||
].some(arg => arg === undefined)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (disableEdit) {
|
||||
this._deleteAndNotify('publishEdit');
|
||||
this._deleteAndNotify('rebaseEdit');
|
||||
@@ -1344,6 +1362,17 @@
|
||||
*/
|
||||
_computeAllActions(changeActionsRecord, revisionActionsRecord,
|
||||
primariesRecord, additionalActionsRecord, change) {
|
||||
// Polymer 2: check for undefined
|
||||
if ([
|
||||
changeActionsRecord,
|
||||
revisionActionsRecord,
|
||||
primariesRecord,
|
||||
additionalActionsRecord,
|
||||
change,
|
||||
].some(arg => arg === undefined)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const revisionActionValues = this._getActionValues(revisionActionsRecord,
|
||||
primariesRecord, additionalActionsRecord, ActionType.REVISION);
|
||||
const changeActionValues = this._getActionValues(changeActionsRecord,
|
||||
|
||||
@@ -795,7 +795,12 @@
|
||||
});
|
||||
},
|
||||
|
||||
_paramsAndChangeChanged(value) {
|
||||
_paramsAndChangeChanged(value, change) {
|
||||
// Polymer 2: check for undefined
|
||||
if ([value, change].some(arg => arg === undefined)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the change number or patch range is different, then reset the
|
||||
// selected file index.
|
||||
const patchRangeState = this.viewState.patchRange;
|
||||
|
||||
@@ -60,6 +60,15 @@
|
||||
],
|
||||
|
||||
_computeMessage(changeStatus, commitNum, commitMessage) {
|
||||
// Polymer 2: check for undefined
|
||||
if ([
|
||||
changeStatus,
|
||||
commitNum,
|
||||
commitMessage,
|
||||
].some(arg => arg === undefined)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let newMessage = commitMessage;
|
||||
|
||||
if (changeStatus === 'MERGED') {
|
||||
|
||||
@@ -144,6 +144,11 @@
|
||||
* the corresponding value to be submitted.
|
||||
*/
|
||||
_updateSelectedOption(rebaseOnCurrent, hasParent) {
|
||||
// Polymer 2: check for undefined
|
||||
if ([rebaseOnCurrent, hasParent].some(arg => arg === undefined)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._displayParentOption(rebaseOnCurrent, hasParent)) {
|
||||
this.$.rebaseOnParentInput.checked = true;
|
||||
} else if (this._displayTipOption(rebaseOnCurrent, hasParent)) {
|
||||
|
||||
@@ -137,6 +137,11 @@
|
||||
},
|
||||
|
||||
_computePatchSetDescription(change, patchNum) {
|
||||
// Polymer 2: check for undefined
|
||||
if ([change, patchNum].some(arg => arg === undefined)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const rev = this.getRevisionByPatchNum(change.revisions, patchNum);
|
||||
this._patchsetDescription = (rev && rev.description) ?
|
||||
rev.description.substring(0, PATCH_DESC_MAX_LENGTH) : '';
|
||||
|
||||
@@ -817,6 +817,17 @@
|
||||
},
|
||||
|
||||
_computeFiles(filesByPath, changeComments, patchRange, reviewed, loading) {
|
||||
// Polymer 2: check for undefined
|
||||
if ([
|
||||
filesByPath,
|
||||
changeComments,
|
||||
patchRange,
|
||||
reviewed,
|
||||
loading,
|
||||
].some(arg => arg === undefined)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Await all promises resolving from reload. @See Issue 9057
|
||||
if (loading || !changeComments) { return; }
|
||||
|
||||
@@ -904,6 +915,11 @@
|
||||
},
|
||||
|
||||
_computePatchSetDescription(revisions, patchNum) {
|
||||
// Polymer 2: check for undefined
|
||||
if ([revisions, patchNum].some(arg => arg === undefined)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const rev = this.getRevisionByPatchNum(revisions, patchNum);
|
||||
return (rev && rev.description) ?
|
||||
rev.description.substring(0, PATCH_DESC_MAX_LENGTH) : '';
|
||||
|
||||
@@ -292,6 +292,17 @@
|
||||
|
||||
_resultsChanged(related, submittedTogether, conflicts,
|
||||
cherryPicks, sameTopic) {
|
||||
// Polymer 2: check for undefined
|
||||
if ([
|
||||
related,
|
||||
submittedTogether,
|
||||
conflicts,
|
||||
cherryPicks,
|
||||
sameTopic,
|
||||
].some(arg => arg === undefined)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const results = [
|
||||
related && related.changes,
|
||||
submittedTogether && submittedTogether.changes,
|
||||
|
||||
@@ -623,6 +623,11 @@
|
||||
},
|
||||
|
||||
_changeUpdated(changeRecord, owner) {
|
||||
// Polymer 2: check for undefined
|
||||
if ([changeRecord, owner].some(arg => arg === undefined)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._rebuildReviewerArrays(changeRecord.base, owner);
|
||||
},
|
||||
|
||||
|
||||
@@ -165,6 +165,11 @@
|
||||
},
|
||||
|
||||
_reviewersChanged(changeRecord, owner) {
|
||||
// Polymer 2: check for undefined
|
||||
if ([changeRecord, owner].some(arg => arg === undefined)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let result = [];
|
||||
const reviewers = changeRecord.base;
|
||||
for (const key in reviewers) {
|
||||
|
||||
@@ -742,6 +742,15 @@
|
||||
_whitespaceChanged(
|
||||
preferredWhitespaceLevel, loadedWhitespaceLevel,
|
||||
noRenderOnPrefsChange) {
|
||||
// Polymer 2: check for undefined
|
||||
if ([
|
||||
preferredWhitespaceLevel,
|
||||
loadedWhitespaceLevel,
|
||||
noRenderOnPrefsChange,
|
||||
].some(arg => arg === undefined)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (preferredWhitespaceLevel !== loadedWhitespaceLevel &&
|
||||
!noRenderOnPrefsChange) {
|
||||
this.reload();
|
||||
|
||||
@@ -260,6 +260,11 @@
|
||||
},
|
||||
|
||||
_getFiles(changeNum, patchRangeRecord) {
|
||||
// Polymer 2: check for undefined
|
||||
if ([changeNum, patchRangeRecord].some(arg => arg === undefined)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const patchRange = patchRangeRecord.base;
|
||||
return this.$.restAPI.getChangeFilePathsAsSpeciallySortedArray(
|
||||
changeNum, patchRange).then(files => {
|
||||
@@ -680,6 +685,11 @@
|
||||
},
|
||||
|
||||
_setReviewedObserver(_loggedIn, paramsRecord, _prefs) {
|
||||
// Polymer 2: check for undefined
|
||||
if ([_loggedIn, paramsRecord, _prefs].some(arg => arg === undefined)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const params = paramsRecord.base || {};
|
||||
if (!_loggedIn) { return; }
|
||||
|
||||
|
||||
@@ -297,6 +297,11 @@
|
||||
},
|
||||
|
||||
_enableSelectionObserver(loggedIn, isAttached) {
|
||||
// Polymer 2: check for undefined
|
||||
if ([loggedIn, isAttached].some(arg => arg === undefined)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (loggedIn && isAttached) {
|
||||
this.listen(document, 'selectionchange', '_handleSelectionChange');
|
||||
this.listen(document, 'mouseup', '_handleMouseUp');
|
||||
|
||||
@@ -242,8 +242,13 @@
|
||||
},
|
||||
|
||||
_updateSuggestions(text, threshold, noDebounce) {
|
||||
// Polymer 2: check for undefined
|
||||
if ([text, threshold, noDebounce].some(arg => arg === undefined)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._disableSuggestions) { return; }
|
||||
if (text === undefined || text.length < threshold) {
|
||||
if (text.length < threshold) {
|
||||
this._suggestions = [];
|
||||
this.value = '';
|
||||
return;
|
||||
|
||||
@@ -211,6 +211,11 @@
|
||||
},
|
||||
|
||||
_calculateActionstoShow(showActions, isRobotComment) {
|
||||
// Polymer 2: check for undefined
|
||||
if ([showActions, isRobotComment].some(arg => arg === undefined)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._showHumanActions = showActions && !isRobotComment;
|
||||
this._showRobotActions = showActions && isRobotComment;
|
||||
},
|
||||
@@ -601,6 +606,11 @@
|
||||
},
|
||||
|
||||
_loadLocalDraft(changeNum, patchNum, comment) {
|
||||
// Polymer 2: check for undefined
|
||||
if ([changeNum, patchNum, comment].some(arg => arg === undefined)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only apply local drafts to comments that haven't been saved
|
||||
// remotely, and haven't been given a default message already.
|
||||
//
|
||||
|
||||
@@ -104,6 +104,11 @@
|
||||
},
|
||||
|
||||
_handleValueChange(value, items) {
|
||||
// Polymer 2: check for undefined
|
||||
if ([value, items].some(arg => arg === undefined)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!value) { return; }
|
||||
const selectedObj = items.find(item => {
|
||||
return item.value + '' === value + '';
|
||||
|
||||
@@ -66,6 +66,11 @@
|
||||
* enabled.
|
||||
*/
|
||||
_updateTitle(text, limit, tooltipLimit) {
|
||||
// Polymer 2: check for undefined
|
||||
if ([text, limit, tooltipLimit].some(arg => arg === undefined)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.hasTooltip = !!limit && !!text && text.length > limit;
|
||||
if (this.hasTooltip) {
|
||||
this.setAttribute('title', text.substr(0, tooltipLimit));
|
||||
|
||||
Reference in New Issue
Block a user