From 51113c17e948c5917dbc6846024c60479ddb304f Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 2 Apr 2023 12:10:15 +0200 Subject: [PATCH] Use object-spread when dispatching events in the toolbars This format is more compact, and should be available in all browsers that we currently support; please see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax#browser_compatibility --- web/secondary_toolbar.js | 6 +----- web/toolbar.js | 8 +------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/web/secondary_toolbar.js b/web/secondary_toolbar.js index 346c73152..04b3f7ae5 100644 --- a/web/secondary_toolbar.js +++ b/web/secondary_toolbar.js @@ -203,11 +203,7 @@ class SecondaryToolbar { for (const { element, eventName, close, eventDetails } of this.buttons) { element.addEventListener("click", evt => { if (eventName !== null) { - const details = { source: this }; - for (const property in eventDetails) { - details[property] = eventDetails[property]; - } - this.eventBus.dispatch(eventName, details); + this.eventBus.dispatch(eventName, { source: this, ...eventDetails }); } if (close) { this.close(); diff --git a/web/toolbar.js b/web/toolbar.js index af8bc2158..86ce55ecb 100644 --- a/web/toolbar.js +++ b/web/toolbar.js @@ -150,13 +150,7 @@ class Toolbar { for (const { element, eventName, eventDetails } of this.buttons) { element.addEventListener("click", evt => { if (eventName !== null) { - const details = { source: this }; - if (eventDetails) { - for (const property in eventDetails) { - details[property] = eventDetails[property]; - } - } - this.eventBus.dispatch(eventName, details); + this.eventBus.dispatch(eventName, { source: this, ...eventDetails }); } }); }