diff --git a/lib/browser/api/menu.js b/lib/browser/api/menu.js index 7778717aa478..6af4f6070f42 100644 --- a/lib/browser/api/menu.js +++ b/lib/browser/api/menu.js @@ -189,14 +189,14 @@ Menu.prototype.closePopup = function (window) { } } -Menu.prototype.getMenuItemById = function (items, id) { - if (items instanceof Menu) { - items = items.items - } +Menu.prototype.getMenuItemById = function (id) { + let items = this; + if (items instanceof Menu) items = this.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) + found = items[i].submenu.getMenuItemById(id) } } return found