Make callback work for old-style Menu.popup call

While the old-style Menu.popup has been deprecated, it is still being
used widely in apps and even in Electron itself.
This commit is contained in:
Cheng Zhao 2018-01-01 17:17:01 +09:00
parent 2ec3b8ce76
commit 73d78d345a
2 changed files with 10 additions and 0 deletions

View file

@ -56,6 +56,11 @@ Menu.prototype.popup = function (window, x, y, positioningItem) {
[newPosition, newY, newX, newWindow] = [y, x, window, null]
}
// menu.popup([w], x, y, callback)
if (typeof newPosition === 'function') {
callback = newPosition
}
// menu.popup({})
if (window != null && window.constructor === Object) {
opts = window