diff --git a/lib/browser/api/menu-item-roles.js b/lib/browser/api/menu-item-roles.js index a6a985a5e2b4..aaebd56223b4 100644 --- a/lib/browser/api/menu-item-roles.js +++ b/lib/browser/api/menu-item-roles.js @@ -125,21 +125,21 @@ exports.execute = function (role, focusedWindow) { return true } - if (focusedWindow != null) { - if (windowMethod) { - if (typeof windowMethod === 'function') { - windowMethod(focusedWindow) - } else { - focusedWindow[windowMethod]() - } - return true - } else if (webContentsMethod) { - const {webContents} = focusedWindow - if (webContents) { - webContents[webContentsMethod]() - } - return true + if (windowMethod && focusedWindow != null) { + if (typeof windowMethod === 'function') { + windowMethod(focusedWindow) + } else { + focusedWindow[windowMethod]() } + return true + } + + if (webContentsMethod && focusedWindow != null) { + const {webContents} = focusedWindow + if (webContents) { + webContents[webContentsMethod]() + } + return true } return false