Directly assign submenu when constructor is Menu

This commit is contained in:
Kevin Sawicki 2015-12-07 11:16:36 -08:00
parent 83c69b56a4
commit 96ef09742c

View file

@ -26,8 +26,11 @@ class MenuItem
{click, @selector, @type, @role, @label, @sublabel, @accelerator, @icon, @enabled, @visible, @checked} = options
if options.submenu? and options.submenu.constructor isnt Menu
@submenu = Menu.buildFromTemplate options.submenu
if options.submenu?
if options.submenu.constructor is Menu
@submenu = options.submenu
else
@submenu = Menu.buildFromTemplate options.submenu
@type = 'submenu' if not @type? and @submenu?
throw new Error('Invalid submenu') if @type is 'submenu' and @submenu?.constructor isnt Menu