inherit user-specific MenuItem properties more safely
authorZeke Sikelianos <zeke@sikelianos.com>
Mon, 10 Oct 2016 21:40:49 +0000 (14:40 -0700)
committerZeke Sikelianos <zeke@sikelianos.com>
Mon, 10 Oct 2016 21:40:49 +0000 (14:40 -0700)
lib/browser/api/menu-item.js

index 8103aaf2b7e9fcfb0e6d456382b0f22bd0975e28..98b8e9980e281e3032812f04c4aa8d1b2f59daf1 100644 (file)
@@ -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)