Don't overwrite existing fields when build menu from template.

This commit is contained in:
Cheng Zhao 2013-08-15 16:09:34 +08:00
parent c858066709
commit c700d291e5
2 changed files with 2 additions and 2 deletions

View file

@ -6,7 +6,7 @@ class MenuItem
constructor: (options) ->
Menu = require 'menu'
{click, selector, @type, @label, @sublabel, @accelerator, @enabled, @visible, @checked, @groupId, @submenu} = options
{click, @selector, @type, @label, @sublabel, @accelerator, @enabled, @visible, @checked, @groupId, @submenu} = options
@type = 'submenu' if not @type? and @submenu?
throw new Error('Invalid submenu') if @type is 'submenu' and @submenu?.constructor isnt Menu

View file

@ -58,7 +58,7 @@ Menu.buildFromTemplate = (template) ->
item.submenu = Menu.buildFromTemplate item.submenu if item.submenu?
menuItem = new MenuItem(item)
menuItem[key] = value for key, value of item
menuItem[key] = value for key, value of item when not menuItem[key]?
menu.append menuItem