From 508b6147694ff2706fb6f016a2a064971f46d3b6 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Mon, 23 Oct 2017 22:33:23 -0400 Subject: [PATCH] remove excess code in delegate --- lib/browser/api/menu.js | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) 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: () => {