diff --git a/browser/api/lib/menu-item.coffee b/browser/api/lib/menu-item.coffee index 2764a0b45a95..aeae1f57620a 100644 --- a/browser/api/lib/menu-item.coffee +++ b/browser/api/lib/menu-item.coffee @@ -20,9 +20,9 @@ class MenuItem throw new Error('Unknown menu type') if MenuItem.types.indexOf(@type) is -1 @commandId = ++nextCommandId - @click = -> + @click = => if typeof click is 'function' - click() + click.apply this, arguments else if typeof selector is 'string' Menu.sendActionToFirstResponder selector diff --git a/browser/api/lib/menu.coffee b/browser/api/lib/menu.coffee index d4d2dafbf2a8..52c5f2426dad 100644 --- a/browser/api/lib/menu.coffee +++ b/browser/api/lib/menu.coffee @@ -37,7 +37,9 @@ Menu::insert = (pos, item) -> isCommandIdEnabled: (commandId) => @commandsMap[commandId]?.enabled isCommandIdVisible: (commandId) => @commandsMap[commandId]?.visible getAcceleratorForCommandId: (commandId) => @commandsMap[commandId]?.accelerator - executeCommand: (commandId) => @commandsMap[commandId]?.click() + executeCommand: (commandId) => + activeItem = @commandsMap[commandId] + activeItem.click(activeItem) if activeItem? @items.splice pos, 0, item @commandsMap[item.commandId] = item