PDA

View Full Version : Suggestion: Allow empty items array in Ext.Container



glenn
17 Dec 2008, 9:19 PM
If you pass an empty items array to an Ext.Container constructor it will fail. Firebug simply reports the error as "comp is undefined" and this problem can be quite hard for the programmer to track down.

The documentation is silent on how to pass a zero number of items so it's arguable whether this is a bug or not. Regardless, I think it would be more consistent and intuitive to allow an empty items array, and would make it easier to build such a list dynamically with a graceful handling of the trivial case where no items get added.

I therefore suggest that the code in the initComponent function of Ext.Container be amended as follows:



if(items){
delete this.items;
if(!Ext.isArray(items)){
this.add(items);
}else if(items.length > 0){
this.add.apply(this, items);
}
}


Thank you