Merge "Replace dispatchEvent with dispatchEventThroughTarget"
This commit is contained in:
@@ -145,16 +145,12 @@ export class GrHovercardAccount extends GestureEventListeners(
|
|||||||
|
|
||||||
_handleClickAddToAttentionSet() {
|
_handleClickAddToAttentionSet() {
|
||||||
if (!this.change || !this.account._account_id) return;
|
if (!this.change || !this.account._account_id) return;
|
||||||
this.dispatchEvent(
|
this.dispatchEventThroughTarget('show-alert', {
|
||||||
new CustomEvent('show-alert', {
|
|
||||||
detail: {
|
detail: {
|
||||||
message: 'Saving attention set update ...',
|
message: 'Saving attention set update ...',
|
||||||
dismissOnNavigation: true,
|
dismissOnNavigation: true,
|
||||||
},
|
},
|
||||||
composed: true,
|
});
|
||||||
bubbles: true,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
// We are deliberately updating the UI before making the API call. It is a
|
// We are deliberately updating the UI before making the API call. It is a
|
||||||
// risk that we are taking to achieve a better UX for 99.9% of the cases.
|
// risk that we are taking to achieve a better UX for 99.9% of the cases.
|
||||||
@@ -181,16 +177,12 @@ export class GrHovercardAccount extends GestureEventListeners(
|
|||||||
|
|
||||||
_handleClickRemoveFromAttentionSet() {
|
_handleClickRemoveFromAttentionSet() {
|
||||||
if (!this.change || !this.account._account_id) return;
|
if (!this.change || !this.account._account_id) return;
|
||||||
this.dispatchEvent(
|
this.dispatchEventThroughTarget('show-alert', {
|
||||||
new CustomEvent('show-alert', {
|
|
||||||
detail: {
|
detail: {
|
||||||
message: 'Saving attention set update ...',
|
message: 'Saving attention set update ...',
|
||||||
dismissOnNavigation: true,
|
dismissOnNavigation: true,
|
||||||
},
|
},
|
||||||
composed: true,
|
});
|
||||||
bubbles: true,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
// We are deliberately updating the UI before making the API call. It is a
|
// We are deliberately updating the UI before making the API call. It is a
|
||||||
// risk that we are taking to achieve a better UX for 99.9% of the cases.
|
// risk that we are taking to achieve a better UX for 99.9% of the cases.
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ suite('gr-hovercard-account tests', () => {
|
|||||||
const showAlertListener = sinon.spy();
|
const showAlertListener = sinon.spy();
|
||||||
const hideAlertListener = sinon.spy();
|
const hideAlertListener = sinon.spy();
|
||||||
const updatedListener = sinon.spy();
|
const updatedListener = sinon.spy();
|
||||||
element.addEventListener('show-alert', showAlertListener);
|
element._target.addEventListener('show-alert', showAlertListener);
|
||||||
element._target.addEventListener('hide-alert', hideAlertListener);
|
element._target.addEventListener('hide-alert', hideAlertListener);
|
||||||
element._target.addEventListener('attention-set-updated', updatedListener);
|
element._target.addEventListener('attention-set-updated', updatedListener);
|
||||||
|
|
||||||
@@ -149,7 +149,7 @@ suite('gr-hovercard-account tests', () => {
|
|||||||
const showAlertListener = sinon.spy();
|
const showAlertListener = sinon.spy();
|
||||||
const hideAlertListener = sinon.spy();
|
const hideAlertListener = sinon.spy();
|
||||||
const updatedListener = sinon.spy();
|
const updatedListener = sinon.spy();
|
||||||
element.addEventListener('show-alert', showAlertListener);
|
element._target.addEventListener('show-alert', showAlertListener);
|
||||||
element._target.addEventListener('hide-alert', hideAlertListener);
|
element._target.addEventListener('hide-alert', hideAlertListener);
|
||||||
element._target.addEventListener('attention-set-updated', updatedListener);
|
element._target.addEventListener('attention-set-updated', updatedListener);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user