From 1e2c571075a1b8b44340f012f074c11e17e5c77c Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 4 Aug 2026 12:41:46 +0200 Subject: [PATCH] Shorten the `Menu` constructor a tiny bit The fallback path used when the `menuItems` aren't provided/correct can be simplified, since the manual loop isn't necessary. --- web/menu.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/web/menu.js b/web/menu.js index 501325ef5..9408816b4 100644 --- a/web/menu.js +++ b/web/menu.js @@ -39,14 +39,9 @@ class Menu { constructor(menuContainer, triggeringButton, menuItems) { this.#menu = menuContainer; this.#triggeringButton = triggeringButton; - if (Array.isArray(menuItems)) { - this.#menuItems = menuItems; - } else { - this.#menuItems = []; - for (const button of this.#menu.querySelectorAll("button")) { - this.#menuItems.push(button); - } - } + this.#menuItems = Array.isArray(menuItems) + ? menuItems + : [...this.#menu.querySelectorAll("button")]; this.#setUpMenu(); }