Threaded View
-
17 Nov 2012 5:37 PM #1
Array.prototype.remove and Ext.apply - wtf ??? (bug with config of type of Array)
Array.prototype.remove and Ext.apply - wtf ??? (bug with config of type of Array)
Due to some reasons I use this code:
Ext.apply , defined in ext-base.js looks like:Code:var config = ['a', 'b']; Ext.apply(o, config);
Ok, as we see, it MUST work with array (typeof array is 'object'), but wait, Ext has defined such stupid prototype methods: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; };
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)?
Thank you for reporting this bug. We will make it our priority to review this report.


Reply With Quote