diff --git a/lib/browser/api/menu.js b/lib/browser/api/menu.js index 9877d81bb9b6..b123c8e46bbd 100644 --- a/lib/browser/api/menu.js +++ b/lib/browser/api/menu.js @@ -16,31 +16,19 @@ Menu.prototype._init = function () { this.groupsMap = {} this.items = [] this.delegate = { - isCommandIdChecked: (commandId) => { - var command = this.commandsMap[commandId] - return command != null ? command.checked : undefined - }, - isCommandIdEnabled: (commandId) => { - var command = this.commandsMap[commandId] - return command != null ? command.enabled : undefined - }, - isCommandIdVisible: (commandId) => { - var command = this.commandsMap[commandId] - return command != null ? command.visible : undefined - }, - getAcceleratorForCommandId: (commandId, useDefaultAccelerator) => { - const command = this.commandsMap[commandId] - if (command == null) return - if (command.accelerator != null) return command.accelerator + isCommandIdChecked: id => this.commandsMap[id].checked, + isCommandIdEnabled: id => this.commandsMap[id].enabled, + isCommandIdVisible: id => this.commandsMap[id].visible, + getAcceleratorForCommandId: (id, useDefaultAccelerator) => { + const command = this.commandsMap[id] + if (command === null) return + if (command.accelerator !== null) return command.accelerator if (useDefaultAccelerator) return command.getDefaultRoleAccelerator() }, - getIconForCommandId: (commandId) => { - var command = this.commandsMap[commandId] - return command != null ? command.icon : undefined - }, - executeCommand: (event, commandId) => { - const command = this.commandsMap[commandId] - if (command == null) return + getIconForCommandId: id => this.commandsMap[id].icon, + executeCommand: (event, id) => { + const command = this.commandsMap[id] + if (command === null) return command.click(event, BrowserWindow.getFocusedWindow(), webContents.getFocusedWebContents()) }, menuWillShow: () => {