Fix dockMenu not being referenced in JavaScript (#12062)

* Fix dockMenu not being referenced in JavaScript

* spec: Test garbage collecting dock menu
This commit is contained in:
Cheng Zhao 2018-02-27 15:15:06 +09:00 committed by shelley vohr
parent 53229e3d6c
commit 35cbe9d140
2 changed files with 24 additions and 2 deletions

View file

@ -10,6 +10,8 @@ const electron = require('electron')
const {deprecate, Menu} = electron
const {EventEmitter} = require('events')
let dockMenu = null
// App is an EventEmitter.
Object.setPrototypeOf(App.prototype, EventEmitter.prototype)
EventEmitter.call(app)
@ -49,7 +51,13 @@ if (process.platform === 'darwin') {
hide: bindings.dockHide,
show: bindings.dockShow,
isVisible: bindings.dockIsVisible,
setMenu: bindings.dockSetMenu,
setMenu (menu) {
dockMenu = menu
bindings.dockSetMenu(menu)
},
getMenu () {
return dockMenu
},
setIcon: bindings.dockSetIcon
}
}