preserve custom properties passed to MenuItem constructor
This commit is contained in:
parent
018575de71
commit
16b3962b66
2 changed files with 22 additions and 15 deletions
|
@ -7,18 +7,8 @@ let nextCommandId = 0
|
|||
const MenuItem = function (options) {
|
||||
const {Menu} = require('electron')
|
||||
|
||||
this.selector = options.selector
|
||||
this.type = options.type
|
||||
this.role = options.role
|
||||
this.label = options.label
|
||||
this.sublabel = options.sublabel
|
||||
this.accelerator = options.accelerator
|
||||
this.icon = options.icon
|
||||
this.enabled = options.enabled
|
||||
this.visible = options.visible
|
||||
this.checked = options.checked
|
||||
Object.assign(this, options)
|
||||
|
||||
this.submenu = options.submenu
|
||||
if (this.submenu != null && this.submenu.constructor !== Menu) {
|
||||
this.submenu = Menu.buildFromTemplate(this.submenu)
|
||||
}
|
||||
|
@ -70,10 +60,7 @@ MenuItem.prototype.getDefaultRoleAccelerator = function () {
|
|||
return roles.getDefaultAccelerator(this.role)
|
||||
}
|
||||
|
||||
MenuItem.prototype.overrideProperty = function (name, defaultValue) {
|
||||
if (defaultValue == null) {
|
||||
defaultValue = null
|
||||
}
|
||||
MenuItem.prototype.overrideProperty = function (name, defaultValue = null) {
|
||||
if (this[name] == null) {
|
||||
this[name] = defaultValue
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue