Merge pull request #11961 from electron/fix-bw-callback

add conditional for menu.popup(window, callback)
This commit is contained in:
shelley vohr 2018-02-19 19:54:20 -05:00 committed by GitHub
commit 459a5e3a1f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View file

@ -58,8 +58,9 @@ Menu.prototype.popup = function (window, x, y, positioningItem) {
callback = newPosition
}
// menu.popup({})
if (window != null && window.constructor === Object) {
// menu.popup({}) || menu.popup(window, callback)
if ((window != null && window.constructor === Object) ||
(x && typeof x === 'function')) {
opts = window
callback = arguments[1]
// menu.popup(window, {})

View file

@ -383,6 +383,11 @@ describe('Menu module', () => {
assert.equal(y, 101)
})
it('works with a given BrowserWindow, no options, and a callback', (done) => {
menu.popup(w, () => done())
menu.closePopup()
})
it('calls the callback', (done) => {
menu.popup({}, () => done())
menu.closePopup()