add first pass at getMenuItemById
This commit is contained in:
parent
fb6a4febb0
commit
ea42851c9b
1 changed files with 13 additions and 0 deletions
|
@ -189,6 +189,19 @@ Menu.prototype.closePopup = function (window) {
|
|||
}
|
||||
}
|
||||
|
||||
Menu.prototype.getMenuItemById = function (items, id) {
|
||||
if (items instanceof Menu) {
|
||||
items = items.items;
|
||||
}
|
||||
let found = items.find(item => item.id === id) || false;
|
||||
for(let i = 0, length = items.length; !found && i < length; i++) {
|
||||
if (items[i].submenu) {
|
||||
found = this.getMenuItemById(items[i].submenu, id);
|
||||
}
|
||||
}
|
||||
return found;
|
||||
};
|
||||
|
||||
Menu.prototype.append = function (item) {
|
||||
return this.insert(this.getItemCount(), item)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue