mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
inherit user-specific MenuItem properties more safely
This commit is contained in:
@@ -7,12 +7,10 @@ let nextCommandId = 0
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user