Merge pull request #21700 from Snuffleupagus/Menu-constructor-shorten

Shorten the `Menu` constructor a tiny bit
This commit is contained in:
Tim van der Meij 2026-08-04 20:47:42 +02:00 committed by GitHub
commit b75d2b62a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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();
}