rewrite method with only id parameter

This commit is contained in:
Shelley Vohr 2017-09-26 12:05:45 -04:00
parent 5217718d7b
commit 4753ada7a9
No known key found for this signature in database
GPG key ID: F13993A75599653C

View file

@ -189,14 +189,14 @@ Menu.prototype.closePopup = function (window) {
} }
} }
Menu.prototype.getMenuItemById = function (items, id) { Menu.prototype.getMenuItemById = function (id) {
if (items instanceof Menu) { let items = this;
items = items.items if (items instanceof Menu) items = this.items
}
let found = items.find(item => item.id === id) || false let found = items.find(item => item.id === id) || false
for (let i = 0, length = items.length; !found && i < length; i++) { for (let i = 0, length = items.length; !found && i < length; i++) {
if (items[i].submenu) { if (items[i].submenu) {
found = this.getMenuItemById(items[i].submenu, id) found = items[i].submenu.getMenuItemById(id)
} }
} }
return found return found