diff --git a/src/platform/web/ui/general/Menu.js b/src/platform/web/ui/general/Menu.js index 2fed5e2d..be5dea1d 100644 --- a/src/platform/web/ui/general/Menu.js +++ b/src/platform/web/ui/general/Menu.js @@ -27,18 +27,7 @@ export class Menu extends TemplateView { } render(t) { - return t.ul({className: "menu", role: "menu"}, this._options.map(o => { - const className = { - destructive: o.destructive, - }; - if (o.icon) { - className.icon = true; - className[o.icon] = true; - } - return t.li({ - className, - }, t.button({onClick: o.callback}, o.label)); - })); + return t.ul({className: "menu", role: "menu"}, this._options.map(o => o.toDOM(t))); } } @@ -59,4 +48,17 @@ class MenuOption { this.destructive = true; return this; } + + toDOM(t) { + const className = { + destructive: this.destructive, + }; + if (this.icon) { + className.icon = true; + className[this.icon] = true; + } + return t.li({ + className, + }, t.button({onClick: this.callback}, this.label)); + } }