Array.prototype.remove and Ext.apply - wtf ??? (bug with config of type of Array)
Due to some reasons I use this code:
Code:
var config = ['a', 'b'];
Ext.apply(o, config);
Ext.apply , defined in ext-base.js looks like:
Code:
Ext.apply = function(o, c, defaults){
// no "this" reference for friendly out of scope calls
if(defaults){
Ext.apply(o, defaults);
}
if(o && c && typeof c == 'object'){
for(var p in c){
o[p] = c[p];
}
}
return o;
};
Ok, as we see, it MUST work with array (typeof array is 'object'), but wait, Ext has defined such stupid prototype methods:
Code:
Ext.applyIf(Array.prototype, {
/**
* Checks whether or not the specified object exists in the array.
* @param {Object} o The object to check for
* @param {Number} from (Optional) The index at which to begin the search
* @return {Number} The index of o in the array (or -1 if it is not found)
*/
indexOf : function(o, from){
var len = this.length;
from = from || 0;
from += (from < 0) ? len : 0;
for (; from < len; ++from){
if(this[from] === o){
return from;
}
}
return -1;
},
/**
* Removes the specified object from the array. If the object is not found nothing happens.
* @param {Object} o The object to remove
* @return {Array} this array
*/
remove : function(o){
var index = this.indexOf(o);
if(index != -1){
this.splice(index, 1);
}
return this;
}
});
Nice, remove() is enumerable! This is great, because of this brokes all for (var p in o) iterations !
Ext developers are happy, because of they can call [0,1].remove(0) instead of [0,1].splice(0,1).
But I am sad because of my server-side provides component states as arrays, not objects.
Is ExtJS 3 supported? Where is bug-tracker ? Can someone offer workaround, please (I am new to javascript and especially ExtJS)?