PDA

View Full Version : [FIXED][3.0] Menu getItemArgs (isXType vs instanceof)



stever
7 Apr 2009, 2:23 PM
I suppose this one may be considered a difference of opinion, but it caused upgrade havoc so I think it is at least worth thinking about. In Menu.js, getItemArgs looks like this now:

Original:

getItemArgs: function(c) {
var isMenuItem = c.isXType(Ext.menu.Item);
return {
isMenuItem: isMenuItem,
needsIcon: !isMenuItem && (c.icon || c.iconCls),
icon: c.icon || Ext.BLANK_IMAGE_URL,
iconCls: 'x-menu-item-icon ' + (c.iconCls || ''),
itemId: 'x-menu-el-' + c.id,
itemCls: 'x-menu-list-item ' + (this.extraCls || '')
};
}

As opposed to this:
Proposed:

getItemArgs: function(c) {
var isMenuItem = c instanceof Ext.menu.Item;
return {
isMenuItem: isMenuItem,
needsIcon: !isMenuItem && (c.icon || c.iconCls),
icon: c.icon || Ext.BLANK_IMAGE_URL,
iconCls: 'x-menu-item-icon ' + (c.iconCls || ''),
itemId: 'x-menu-el-' + c.id,
itemCls: 'x-menu-list-item ' + (this.extraCls || '')
};
}

The side effect of using isXType is that every subclass must register an xtype or the menus get created all wrong. I prefer the way Ext2 did it, which is the proposed change (use instanceof).

evant
7 Apr 2009, 3:14 PM
Changed back for backwards compat.