Set composed: true on all bubbled events

In Polymer 2, and when using native shadow DOM, events that do not have
`composed: true` set do not cross shadow DOM boundaries. I cross checked
and all these events seem to be handled outside of the component that
fires them, so they need this.

Change-Id: Iee8d2d545f3b1ea0bfb624648637fd190b952feb
This commit is contained in:
Ole Rehmsen
2019-05-16 14:43:01 +02:00
parent 8189f32d58
commit c82baba734
37 changed files with 192 additions and 102 deletions

View File

@@ -95,7 +95,8 @@
// For a new section, this is not fired because new permissions and
// rules have to be added in order to save, modifying the ref is not
// enough.
this.dispatchEvent(new CustomEvent('access-modified', {bubbles: true}));
this.dispatchEvent(new CustomEvent(
'access-modified', {bubbles: true, composed: true}));
}
this.section.value.updatedId = this.section.id;
},
@@ -199,12 +200,13 @@
_handleRemoveReference() {
if (this.section.value.added) {
this.dispatchEvent(new CustomEvent('added-section-removed',
{bubbles: true}));
this.dispatchEvent(new CustomEvent(
'added-section-removed', {bubbles: true, composed: true}));
}
this._deleted = true;
this.section.value.deleted = true;
this.dispatchEvent(new CustomEvent('access-modified', {bubbles: true}));
this.dispatchEvent(
new CustomEvent('access-modified', {bubbles: true, composed: true}));
},
_handleUndoRemove() {

View File

@@ -205,6 +205,7 @@
this.dispatchEvent(new CustomEvent('show-alert', {
detail: {message: SAVING_ERROR_TEXT},
bubbles: true,
composed: true,
}));
return err;
}

View File

@@ -137,17 +137,19 @@
_handleValueChange() {
this.permission.value.modified = true;
// Allows overall access page to know a change has been made.
this.dispatchEvent(new CustomEvent('access-modified', {bubbles: true}));
this.dispatchEvent(
new CustomEvent('access-modified', {bubbles: true, composed: true}));
},
_handleRemovePermission() {
if (this.permission.value.added) {
this.dispatchEvent(new CustomEvent('added-permission-removed',
{bubbles: true}));
this.dispatchEvent(new CustomEvent(
'added-permission-removed', {bubbles: true, composed: true}));
}
this._deleted = true;
this.permission.value.deleted = true;
this.dispatchEvent(new CustomEvent('access-modified', {bubbles: true}));
this.dispatchEvent(
new CustomEvent('access-modified', {bubbles: true, composed: true}));
},
_handleRulesChanged(changeRecord) {
@@ -273,7 +275,8 @@
const value = this._rules[this._rules.length - 1].value;
value.added = true;
this.set(['permission', 'value', 'rules', groupId], value);
this.dispatchEvent(new CustomEvent('access-modified', {bubbles: true}));
this.dispatchEvent(
new CustomEvent('access-modified', {bubbles: true, composed: true}));
},
_computeHasRange(name) {

View File

@@ -406,8 +406,11 @@
if (!Object.keys(addRemoveObj.add).length &&
!Object.keys(addRemoveObj.remove).length &&
!addRemoveObj.parent) {
this.dispatchEvent(new CustomEvent('show-alert',
{detail: {message: NOTHING_TO_SAVE}, bubbles: true}));
this.dispatchEvent(new CustomEvent('show-alert', {
detail: {message: NOTHING_TO_SAVE},
bubbles: true,
composed: true,
}));
return;
}
const obj = {

View File

@@ -34,7 +34,8 @@
*/
_onCommandTap() {
this.dispatchEvent(new CustomEvent('command-tap', {bubbles: true}));
this.dispatchEvent(
new CustomEvent('command-tap', {bubbles: true, composed: true}));
},
});
})();

View File

@@ -75,8 +75,9 @@
_handleRunningGC() {
return this.$.restAPI.runRepoGC(this.repo).then(response => {
if (response.status === 200) {
this.dispatchEvent(new CustomEvent('show-alert',
{detail: {message: GC_MESSAGE}, bubbles: true}));
this.dispatchEvent(new CustomEvent(
'show-alert',
{detail: {message: GC_MESSAGE}, bubbles: true, composed: true}));
}
});
},
@@ -100,8 +101,9 @@
const message = change ?
CREATE_CHANGE_SUCCEEDED_MESSAGE :
CREATE_CHANGE_FAILED_MESSAGE;
this.dispatchEvent(new CustomEvent('show-alert',
{detail: {message}, bubbles: true}));
this.dispatchEvent(new CustomEvent(
'show-alert',
{detail: {message}, bubbles: true, composed: true}));
if (!change) { return; }
Gerrit.Nav.navigateToRelativeUrl(Gerrit.Nav.getEditUrlForDiff(

View File

@@ -123,8 +123,8 @@
notifyPath: `${name}.${notifyPath}`,
};
this.dispatchEvent(new CustomEvent(this.PLUGIN_CONFIG_CHANGED,
{detail, bubbles: true}));
this.dispatchEvent(new CustomEvent(
this.PLUGIN_CONFIG_CHANGED, {detail, bubbles: true, composed: true}));
},
});
})();

View File

@@ -151,7 +151,8 @@ limitations under the License.
const select = element.$$('select');
assert.ok(select);
select.value = 'newTest';
select.dispatchEvent(new Event('change', {bubbles: true}));
select.dispatchEvent(new Event(
'change', {bubbles: true, composed: true}));
flushAsynchronousOperations();
assert.isTrue(buildStub.called);

View File

@@ -210,12 +210,13 @@
_handleRemoveRule() {
if (this.rule.value.added) {
this.dispatchEvent(new CustomEvent('added-rule-removed',
{bubbles: true}));
this.dispatchEvent(new CustomEvent(
'added-rule-removed', {bubbles: true, composed: true}));
}
this._deleted = true;
this.rule.value.deleted = true;
this.dispatchEvent(new CustomEvent('access-modified', {bubbles: true}));
this.dispatchEvent(
new CustomEvent('access-modified', {bubbles: true, composed: true}));
},
_handleUndoRemove() {
@@ -237,7 +238,8 @@
if (!this._originalRuleValues) { return; }
this.rule.value.modified = true;
// Allows overall access page to know a change has been made.
this.dispatchEvent(new CustomEvent('access-modified', {bubbles: true}));
this.dispatchEvent(
new CustomEvent('access-modified', {bubbles: true, composed: true}));
},
_setOriginalRuleValues(value) {

View File

@@ -214,6 +214,7 @@
this.set('change.reviewed', newVal);
this.dispatchEvent(new CustomEvent('toggle-reviewed', {
bubbles: true,
composed: true,
detail: {change: this.change, reviewed: newVal},
}));
},

View File

@@ -29,7 +29,8 @@
_handleCreateTap(e) {
e.preventDefault();
this.dispatchEvent(new CustomEvent('create-tap', {bubbles: true}));
this.dispatchEvent(
new CustomEvent('create-tap', {bubbles: true, composed: true}));
},
});
})();

View File

@@ -118,8 +118,8 @@
_inputTextChanged(text) {
if (text.length && this.allowAnyInput) {
this.dispatchEvent(new CustomEvent('account-text-changed',
{bubbles: true}));
this.dispatchEvent(new CustomEvent(
'account-text-changed', {bubbles: true, composed: true}));
}
},

View File

@@ -123,8 +123,11 @@
// Repopulate the input with what the user tried to enter and have
// a toast tell them why they can't enter it.
this.$.entry.setText(reviewer);
this.dispatchEvent(new CustomEvent('show-alert',
{detail: {message: VALID_EMAIL_ALERT}, bubbles: true}));
this.dispatchEvent(new CustomEvent('show-alert', {
detail: {message: VALID_EMAIL_ALERT},
bubbles: true,
composed: true,
}));
return false;
} else {
const account = {email: reviewer, _pendingAdd: true};

View File

@@ -221,8 +221,8 @@
this._settingTopic = false;
this.set(['change', 'topic'], newTopic);
if (newTopic !== lastTopic) {
this.dispatchEvent(
new CustomEvent('topic-changed', {bubbles: true}));
this.dispatchEvent(new CustomEvent(
'topic-changed', {bubbles: true, composed: true}));
}
});
},
@@ -246,8 +246,8 @@
this.change._number, {add: [newHashtag]}).then(newHashtag => {
this.set(['change', 'hashtags'], newHashtag);
if (newHashtag !== lastHashtag) {
this.dispatchEvent(
new CustomEvent('hashtag-changed', {bubbles: true}));
this.dispatchEvent(new CustomEvent(
'hashtag-changed', {bubbles: true, composed: true}));
}
});
},
@@ -378,7 +378,7 @@
target.disabled = false;
this.set(['change', 'topic'], '');
this.dispatchEvent(
new CustomEvent('topic-changed', {bubbles: true}));
new CustomEvent('topic-changed', {bubbles: true, composed: true}));
}).catch(err => {
target.disabled = false;
return;

View File

@@ -1599,32 +1599,44 @@ limitations under the License.
sandbox.stub(Gerrit.Nav, 'navigateToRelativeUrl');
// Delete
fileList.dispatchEvent(new CustomEvent('file-action-tap',
{detail: {action: Actions.DELETE.id, path: 'foo'}, bubbles: true}));
fileList.dispatchEvent(new CustomEvent('file-action-tap', {
detail: {action: Actions.DELETE.id, path: 'foo'},
bubbles: true,
composed: true,
}));
flushAsynchronousOperations();
assert.isTrue(controls.openDeleteDialog.called);
assert.equal(controls.openDeleteDialog.lastCall.args[0], 'foo');
// Restore
fileList.dispatchEvent(new CustomEvent('file-action-tap',
{detail: {action: Actions.RESTORE.id, path: 'foo'}, bubbles: true}));
fileList.dispatchEvent(new CustomEvent('file-action-tap', {
detail: {action: Actions.RESTORE.id, path: 'foo'},
bubbles: true,
composed: true,
}));
flushAsynchronousOperations();
assert.isTrue(controls.openRestoreDialog.called);
assert.equal(controls.openRestoreDialog.lastCall.args[0], 'foo');
// Rename
fileList.dispatchEvent(new CustomEvent('file-action-tap',
{detail: {action: Actions.RENAME.id, path: 'foo'}, bubbles: true}));
fileList.dispatchEvent(new CustomEvent('file-action-tap', {
detail: {action: Actions.RENAME.id, path: 'foo'},
bubbles: true,
composed: true,
}));
flushAsynchronousOperations();
assert.isTrue(controls.openRenameDialog.called);
assert.equal(controls.openRenameDialog.lastCall.args[0], 'foo');
// Open
fileList.dispatchEvent(new CustomEvent('file-action-tap',
{detail: {action: Actions.OPEN.id, path: 'foo'}, bubbles: true}));
fileList.dispatchEvent(new CustomEvent('file-action-tap', {
detail: {action: Actions.OPEN.id, path: 'foo'},
bubbles: true,
composed: true,
}));
flushAsynchronousOperations();
assert.isTrue(Gerrit.Nav.getEditUrlForDiff.called);

View File

@@ -133,7 +133,8 @@
const name = e.target.selectedItem.name;
const value = e.target.selectedItem.getAttribute('value');
this.dispatchEvent(new CustomEvent(
'labels-changed', {detail: {name, value}, bubbles: true}));
'labels-changed',
{detail: {name, value}, bubbles: true, composed: true}));
},
_computeAnyPermittedLabelValues(permittedLabels, label) {

View File

@@ -228,6 +228,7 @@
e.preventDefault();
this.dispatchEvent(new CustomEvent('message-anchor-tap', {
bubbles: true,
composed: true,
detail: {id: this.message.id},
}));
},

View File

@@ -150,7 +150,8 @@ limitations under the License.
flush(() => {
const textarea = element.$.textarea.getNativeTextarea();
textarea.value = 'LGTM';
textarea.dispatchEvent(new CustomEvent('input', {bubbles: true}));
textarea.dispatchEvent(new CustomEvent(
'input', {bubbles: true, composed: true}));
const labelScoreRows = Polymer.dom(element.$.labelScores.root)
.querySelector('gr-label-score-row[name="Code-Review"]');
const selectedBtn = Polymer.dom(labelScoreRows.root)

View File

@@ -749,6 +749,7 @@
if (this._sendDisabled) {
this.dispatchEvent(new CustomEvent('show-alert', {
bubbles: true,
composed: true,
detail: {message: EMPTY_REPLY_MESSAGE},
}));
return;
@@ -756,9 +757,11 @@
return this.send(this._includeComments, this.canBeStarted)
.then(keepReviewers => {
this._purgeReviewersPendingRemove(false, keepReviewers);
}).catch(err => {
})
.catch(err => {
this.dispatchEvent(new CustomEvent('show-error', {
bubbles: true,
composed: true,
detail: {message: `Error submitting review ${err}`},
}));
});

View File

@@ -415,7 +415,7 @@ limitations under the License.
assert.isTrue(element.$$('#ccs').allowAnyInput);
assert.isFalse(element.$$('#reviewers').allowAnyInput);
element.$$('#ccs').dispatchEvent(new CustomEvent('account-text-changed',
{bubbles: true}));
{bubbles: true, composed: true}));
assert.isTrue(element._reviewersMutated);
});

View File

@@ -179,7 +179,8 @@ limitations under the License.
const isBinary = !!(this.isImageDiff || this.diff.binary);
this.dispatchEvent(new CustomEvent('render-start', {bubbles: true}));
this.dispatchEvent(new CustomEvent(
'render-start', {bubbles: true, composed: true}));
this._cancelableRenderPromise = util.makeCancelable(
this.$.processor.process(this.diff.content, isBinary)
.then(() => {
@@ -187,7 +188,7 @@ limitations under the License.
this._builder.renderDiff();
}
this.dispatchEvent(new CustomEvent('render-content',
{bubbles: true}));
{bubbles: true, composed: true}));
if (this._diffTooLargeForSyntax()) {
this.$.syntaxLayer.enabled = false;
@@ -196,8 +197,8 @@ limitations under the License.
return this.$.syntaxLayer.process();
})
.then(() => {
this.dispatchEvent(
new CustomEvent('render-syntax', {bubbles: true}));
this.dispatchEvent(new CustomEvent(
'render-syntax', {bubbles: true, composed: true}));
}));
return this._cancelableRenderPromise
.finally(() => { this._cancelableRenderPromise = null; })
@@ -313,7 +314,7 @@ limitations under the License.
this.dispatchEvent(new CustomEvent('show-alert', {
detail: {
message,
}, bubbles: true}));
}, bubbles: true, composed: true}));
throw Error(`Invalid preference value: ${pref}`);
},

View File

@@ -179,8 +179,8 @@ limitations under the License.
element.commentRanges = [{side: 'right'}];
sandbox.stub(element, 'set');
threadEl.dispatchEvent(
new CustomEvent('comment-thread-mouseenter', {bubbles: true}));
threadEl.dispatchEvent(new CustomEvent(
'comment-thread-mouseenter', {bubbles: true, composed: true}));
assert.isFalse(element.set.called);
});
@@ -204,8 +204,8 @@ limitations under the License.
}}];
sandbox.stub(element, 'set');
threadEl.dispatchEvent(
new CustomEvent('comment-thread-mouseenter', {bubbles: true}));
threadEl.dispatchEvent(new CustomEvent(
'comment-thread-mouseenter', {bubbles: true, composed: true}));
assert.isTrue(element.set.called);
const args = element.set.lastCall.args;
assert.deepEqual(args[0], ['commentRanges', 0, 'hovering']);
@@ -221,8 +221,8 @@ limitations under the License.
element.commentRanges = [{side: 'right'}];
sandbox.stub(element, 'set');
threadEl.dispatchEvent(
new CustomEvent('comment-thread-mouseleave', {bubbles: true}));
threadEl.dispatchEvent(new CustomEvent(
'comment-thread-mouseleave', {bubbles: true, composed: true}));
assert.isFalse(element.set.called);
});

View File

@@ -110,7 +110,9 @@
commitRange: Object,
filesWeblinks: {
type: Object,
value() { return {}; },
value() {
return {};
},
notify: true,
},
hidden: {
@@ -309,7 +311,9 @@
},
_getFilesWeblinks(diff) {
if (!this.commitRange) { return {}; }
if (!this.commitRange) {
return {};
}
return {
meta_a: Gerrit.Nav.getFileWebLinks(
this.projectName, this.commitRange.baseCommit, this.path,
@@ -435,7 +439,9 @@
* Report info about the diff response.
*/
_reportDiff(diff) {
if (!diff || !diff.content) { return; }
if (!diff || !diff.content) {
return;
}
// Count the delta lines stemming from normal deltas, and from
// due_to_rebase deltas.
@@ -663,7 +669,7 @@
* @param {!Gerrit.Range=} range
* @return {?Node}
*/
_getThreadEl(lineNum, commentSide, range=undefined) {
_getThreadEl(lineNum, commentSide, range = undefined) {
let line;
if (commentSide === GrDiffBuilder.Side.LEFT) {
line = {beforeNumber: lineNum};
@@ -778,7 +784,8 @@
return this.prefs.ignore_whitespace;
},
_whitespaceChanged(preferredWhitespaceLevel, loadedWhitespaceLevel,
_whitespaceChanged(
preferredWhitespaceLevel, loadedWhitespaceLevel,
noRenderOnPrefsChange) {
if (preferredWhitespaceLevel !== loadedWhitespaceLevel &&
!noRenderOnPrefsChange) {
@@ -831,8 +838,8 @@
},
_handleCommentSaveOrDiscard() {
this.dispatchEvent(new CustomEvent('diff-comments-modified',
{bubbles: true}));
this.dispatchEvent(new CustomEvent(
'diff-comments-modified', {bubbles: true, composed: true}));
},
_removeComment(comment) {

View File

@@ -269,7 +269,7 @@ limitations under the License.
suite('render reporting', () => {
test('starts total and content timer on render-start', done => {
element.dispatchEvent(
new CustomEvent('render-start', {bubbles: true}));
new CustomEvent('render-start', {bubbles: true, composed: true}));
assert.isTrue(element.$.reporting.time.calledWithExactly(
'Diff Total Render'));
assert.isTrue(element.$.reporting.time.calledWithExactly(
@@ -279,7 +279,7 @@ limitations under the License.
test('ends content and starts syntax timer on render-content', done => {
element.dispatchEvent(
new CustomEvent('render-content', {bubbles: true}));
new CustomEvent('render-content', {bubbles: true, composed: true}));
assert.isTrue(element.$.reporting.time.calledWithExactly(
'Diff Syntax Render'));
assert.isTrue(element.$.reporting.timeEnd.calledWithExactly(
@@ -289,7 +289,7 @@ limitations under the License.
test('ends total and syntax timer on render-syntax', done => {
element.dispatchEvent(
new CustomEvent('render-syntax', {bubbles: true}));
new CustomEvent('render-syntax', {bubbles: true, composed: true}));
assert.isTrue(element.$.reporting.timeEnd.calledWithExactly(
'Diff Total Render'));
assert.isTrue(element.$.reporting.timeEnd.calledWithExactly(

View File

@@ -390,12 +390,12 @@
_redispatchHoverEvents(addedThreadEls) {
for (const threadEl of addedThreadEls) {
threadEl.addEventListener('mouseenter', () => {
threadEl.dispatchEvent(
new CustomEvent('comment-thread-mouseenter', {bubbles: true}));
threadEl.dispatchEvent(new CustomEvent(
'comment-thread-mouseenter', {bubbles: true, composed: true}));
});
threadEl.addEventListener('mouseleave', () => {
threadEl.dispatchEvent(
new CustomEvent('comment-thread-mouseleave', {bubbles: true}));
threadEl.dispatchEvent(new CustomEvent(
'comment-thread-mouseleave', {bubbles: true, composed: true}));
});
}
},
@@ -551,6 +551,7 @@
this._getIsParentCommentByLineAndContent(lineEl, contentEl);
this.dispatchEvent(new CustomEvent('create-comment', {
bubbles: true,
composed: true,
detail: {
lineNum,
side,
@@ -727,14 +728,16 @@
_renderDiffTable() {
this._unobserveIncrementalNodes();
if (!this.prefs) {
this.dispatchEvent(new CustomEvent('render', {bubbles: true}));
this.dispatchEvent(
new CustomEvent('render', {bubbles: true, composed: true}));
return;
}
if (this.prefs.context === -1 &&
this._diffLength >= LARGE_DIFF_THRESHOLD_LINES &&
this._safetyBypass === null) {
this._showWarning = true;
this.dispatchEvent(new CustomEvent('render', {bubbles: true}));
this.dispatchEvent(
new CustomEvent('render', {bubbles: true, composed: true}));
return;
}
@@ -744,7 +747,7 @@
this.$.diffBuilder.render(keyLocations, this._getBypassPrefs())
.then(() => {
this.dispatchEvent(
new CustomEvent('render', {bubbles: true}));
new CustomEvent('render', {bubbles: true, composed: true}));
});
},

View File

@@ -762,7 +762,7 @@ limitations under the License.
() => {
Promise.resolve();
element.$.diffBuilder.dispatchEvent(
new CustomEvent('render', {bubbles: true}));
new CustomEvent('render', {bubbles: true, composed: true}));
});
const mock = document.createElement('mock-diff-response');
sandbox.stub(element.$.diffBuilder, 'getDiffLength').returns(10000);

View File

@@ -188,6 +188,7 @@
range.end = line.text.length;
this.dispatchEvent(new CustomEvent('normalize-range', {
bubbles: true,
composed: true,
detail: {lineNum, side},
}));
}

View File

@@ -32,8 +32,9 @@
},
_handleTextareaInput(e) {
this.dispatchEvent(new CustomEvent('content-change',
{detail: {value: e.target.value}, bubbles: true}));
this.dispatchEvent(new CustomEvent(
'content-change',
{detail: {value: e.target.value}, bubbles: true, composed: true}));
},
});
})();

View File

@@ -50,7 +50,7 @@ limitations under the License.
element.addEventListener('content-change', contentChangedHandler);
textarea.value = 'test';
textarea.dispatchEvent(new CustomEvent('input',
{target: textarea, bubbles: true}));
{target: textarea, bubbles: true, composed: true}));
});
});
</script>

View File

@@ -46,8 +46,9 @@
},
_dispatchFileAction(action, path) {
this.dispatchEvent(new CustomEvent('file-action-tap',
{detail: {action, path}, bubbles: true}));
this.dispatchEvent(new CustomEvent(
'file-action-tap',
{detail: {action, path}, bubbles: true, composed: true}));
},
_computeFileActions(actions) {

View File

@@ -104,7 +104,9 @@
},
_paramsChanged(value) {
if (value.view !== Gerrit.Nav.View.EDIT) { return; }
if (value.view !== Gerrit.Nav.View.EDIT) {
return;
}
this._changeNum = value.changeNum;
this._path = value.path;
@@ -134,7 +136,9 @@
_handlePathChanged(e) {
const path = e.detail;
if (path === this._path) { return Promise.resolve(); }
if (path === this._path) {
return Promise.resolve();
}
return this.$.restAPI.renameFileInChangeEdit(this._changeNum,
this._path, path).then(res => {
if (!res.ok) { return; }
@@ -158,8 +162,11 @@
.then(res => {
if (storedContent && storedContent.message &&
storedContent.message !== res.content) {
this.dispatchEvent(new CustomEvent('show-alert',
{detail: {message: RESTORED_MESSAGE}, bubbles: true}));
this.dispatchEvent(new CustomEvent('show-alert', {
detail: {message: RESTORED_MESSAGE},
bubbles: true,
composed: true,
}));
this._newContent = storedContent.message;
} else {
@@ -197,11 +204,14 @@
this.dispatchEvent(new CustomEvent('show-alert', {
detail: {message},
bubbles: true,
composed: true,
}));
},
_computeSaveDisabled(content, newContent, saving) {
if (saving) { return true; }
if (saving) {
return true;
}
return content === newContent;
},
@@ -224,7 +234,9 @@
_handleSaveShortcut(e) {
e.preventDefault();
if (!this._saveDisabled) { this._saveEdit(); }
if (!this._saveDisabled) {
this._saveEdit();
}
},
});
})();

View File

@@ -121,7 +121,7 @@ suite('gr-editor-view tests', () => {
const storeStub = sandbox.spy(element.$.storage, 'setEditableContentItem');
element._newContent = 'test';
element.$.editorEndpoint.dispatchEvent(new CustomEvent('content-change', {
bubbles: true,
bubbles: true, composed: true,
detail: {value: 'new content value'},
}));
element.flushDebouncer('store');

View File

@@ -66,7 +66,9 @@
_getAgreementsUrl(configUrl) {
let url;
if (!configUrl) { return ''; }
if (!configUrl) {
return '';
}
if (configUrl.startsWith('http:') || configUrl.startsWith('https:')) {
url = configUrl;
} else {
@@ -100,8 +102,8 @@
},
_createToast(message) {
this.dispatchEvent(new CustomEvent('show-alert',
{detail: {message}, bubbles: true}));
this.dispatchEvent(new CustomEvent(
'show-alert', {detail: {message}, bubbles: true, composed: true}));
},
_computeShowAgreementsClass(agreements) {
@@ -133,9 +135,13 @@
// then hides the text box and submit button.
_computeHideAgreementClass(name, config) {
for (const key in config) {
if (!config.hasOwnProperty(key)) { continue; }
if (!config.hasOwnProperty(key)) {
continue;
}
for (const prop in config[key]) {
if (!config[key].hasOwnProperty(prop)) { continue; }
if (!config[key].hasOwnProperty(prop)) {
continue;
}
if (name === config[key].name &&
!config[key].auto_verify_group) {
return 'hideAgreementsTextBox';

View File

@@ -414,6 +414,7 @@
this.dispatchEvent(new CustomEvent('show-alert', {
detail: {message: RELOAD_MESSAGE},
bubbles: true,
composed: true,
}));
this.async(() => {
window.location.reload();

View File

@@ -49,6 +49,7 @@
this.set('change.starred', newVal);
this.dispatchEvent(new CustomEvent('toggle-star', {
bubbles: true,
composed: true,
detail: {change: this.change, starred: newVal},
}));
},

View File

@@ -128,7 +128,8 @@
_numPendingDraftRequests: {
type: Object,
value: {number: 0}, // Intentional to share the object across instances.
value:
{number: 0}, // Intentional to share the object across instances.
},
_enableOverlay: {
@@ -230,7 +231,9 @@
*/
save(opt_comment) {
let comment = opt_comment;
if (!comment) { comment = this.comment; }
if (!comment) {
comment = this.comment;
}
this.set('comment.message', this._messageText);
this.editing = false;
@@ -340,7 +343,9 @@
_computeSaveDisabled(draft, comment, resolved) {
// If resolved state has changed and a msg exists, save should be enabled.
if (comment.unresolved === resolved && draft) { return false; }
if (comment.unresolved === resolved && draft) {
return false;
}
return !draft || draft.trim() === '';
},
@@ -376,7 +381,9 @@
},
_messageTextChanged(newValue, oldValue) {
if (!this.comment || (this.comment && this.comment.id)) { return; }
if (!this.comment || (this.comment && this.comment.id)) {
return;
}
this.debounce('store', () => {
const message = this._messageText;
@@ -400,9 +407,12 @@
_handleAnchorTap(e) {
e.preventDefault();
if (!this.comment.line) { return; }
if (!this.comment.line) {
return;
}
this.dispatchEvent(new CustomEvent('comment-anchor-tap', {
bubbles: true,
composed: true,
detail: {
number: this.comment.line || FILE,
side: this.side,
@@ -421,7 +431,9 @@
e.preventDefault();
// Ignore saves started while already saving.
if (this.disabled) { return; }
if (this.disabled) {
return;
}
const timingLabel = this.comment.id ?
REPORT_UPDATE_DRAFT : REPORT_CREATE_DRAFT;
const timer = this.$.reporting.getTimer(timingLabel);
@@ -450,6 +462,7 @@
_handleFix() {
this.dispatchEvent(new CustomEvent('create-fix-comment', {
bubbles: true,
composed: true,
detail: this._getEventPayload(),
}));
},
@@ -512,7 +525,9 @@
},
_getSavingMessage(numPending) {
if (numPending === 0) { return SAVED_MESSAGE; }
if (numPending === 0) {
return SAVED_MESSAGE;
}
return [
SAVING_MESSAGE,
numPending,
@@ -544,8 +559,8 @@
// Note: the event is fired on the body rather than this element because
// this element may not be attached by the time this executes, in which
// case the event would not bubble.
document.body.dispatchEvent(new CustomEvent('show-alert',
{detail: {message}, bubbles: true}));
document.body.dispatchEvent(new CustomEvent(
'show-alert', {detail: {message}, bubbles: true, composed: true}));
}, TOAST_DEBOUNCE_INTERVAL);
},

View File

@@ -96,8 +96,11 @@
this.$.storage.getEditableContentItem(this.storageKey);
if (storedContent && storedContent.message) {
content = storedContent.message;
this.dispatchEvent(new CustomEvent('show-alert',
{detail: {message: RESTORED_MESSAGE}, bubbles: true}));
this.dispatchEvent(new CustomEvent('show-alert', {
detail: {message: RESTORED_MESSAGE},
bubbles: true,
composed: true,
}));
}
}
if (!content) {