From ed1a8d2e4eb77c2e33d5d44118f13331dac43899 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Sun, 27 Oct 2024 23:15:01 +0800 Subject: feat: add id option for Menu-item --- src/MenuItem.mjs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/MenuItem.mjs b/src/MenuItem.mjs index 1035cd1..1d864fd 100644 --- a/src/MenuItem.mjs +++ b/src/MenuItem.mjs @@ -28,10 +28,11 @@ export class Item extends window.HTMLDivElement { * @param {string} [options.style] - The CSS style string * @param {string[]} [options.className] - Additional CSS classes */ - constructor ({ text, innerHTML, title, onclick, style, className }) { + constructor ({ id, text, innerHTML, title, onclick, style, className }) { super() - this.innerHTML = innerHTML ?? text + if (id) this.id = id if (title) this.title = title + this.innerHTML = innerHTML ?? text this.onclick = onclick this.style.cssText = style this.classList.add('menu-item') @@ -62,8 +63,9 @@ export class Folder extends window.HTMLDivElement { * @param {string} [options.innerHTML] - The HTML content of the folder * @param {Item[]} options.items - The submenu items */ - constructor ({ text, innerHTML, items, style }) { + constructor ({ id, text, innerHTML, items, style }) { super() + if (id) this.id = id this.innerHTML = innerHTML ?? text this.classList.add('folder', 'menu-item') this.items = items -- cgit v1.2.3-70-g09d2