From 3719ee0b53ae8cf596711f89a1f1653b35aeaede Mon Sep 17 00:00:00 2001 From: Felix Rieseberg Date: Fri, 8 Dec 2017 14:37:16 -0800 Subject: [PATCH] :wrench: Allow for `menu.popup({})` --- lib/browser/api/menu.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/browser/api/menu.js b/lib/browser/api/menu.js index bec3cce7644e..f50fee6ecb4f 100644 --- a/lib/browser/api/menu.js +++ b/lib/browser/api/menu.js @@ -45,6 +45,7 @@ Menu.prototype._init = function () { Menu.prototype.popup = function (window, x, y, positioningItem) { let [newX, newY, newPosition, newWindow] = [x, y, positioningItem, window] + let opts // menu.popup(x, y, positioningItem) if (!window) { @@ -54,9 +55,16 @@ Menu.prototype.popup = function (window, x, y, positioningItem) { } } + // menu.popup({}) + if (window && typeof window === 'object' && window.constructor && + window.constructor.name !== 'BrowserWindow') { + opts = window // menu.popup(window, {}) - if (x && typeof x === 'object') { - const opts = x + } else if (x && typeof x === 'object') { + opts = x + } + + if (opts) { newX = opts.x newY = opts.y newPosition = opts.positioningItem