const MenuItem = function (options) {
const {Menu} = require('electron')
- // Clone and sanitize the provided options
- options = Object.assign({}, options)
- delete options.overrideProperty
- delete options.overrideReadOnlyProperty
-
- Object.assign(this, options)
+ // Preserve extra fields specified by user
+ for (let key in options) {
+ if (!(key in this)) this[key] = options[key]
+ }
if (this.submenu != null && this.submenu.constructor !== Menu) {
this.submenu = Menu.buildFromTemplate(this.submenu)