
I'm using Ext JSCross-browser JavaScript framework and on the search page I've following error:
Uncaught TypeError: Object function (B){var A=this.indexOf(B);if(A!=-1){this.splice(A,1)}return this} has no method 'match'
Affected code is:
for (var n in userFlags) {
var flagInfo = userFlags[n].match(/(\w+)_(\d+)/);
var flagName = flagInfo[1];
var contentId = flagInfo[2];
...
}
The reason of this error is misuse of the Array class.
See following link:
http://www.sencha.com/forum/showthread.php?6005-Problem-with-Array.index...
The bug isn't in Ext, it's in the misuse of the Array class. If you look at the functions on the Array object they all work with indexes. Arrays themselves do not support string keys. When you add string key'ed properties, do you notice the length doesn't change? You can't slice or pop or splice them?
However, every object in JavaScript supports dynamic expando properties. When you make a call like this:
arrayX['key1'] = 'foo';
you are not doing anything with the Array class, which is why the Array functions don't work on that value. You are simply assigning an expando to that JavaScript object. In fact, arrayX.key1 = 'foo'; does exactly the same thing.
If all you want is a JavaScript object to add expandos to, the syntax is almost identical:
arrayX = {};
arrayX['key1'] = 'foo';
arrayX['key2'] = 'bar';Lastly, why is this in BUGS?? If you want to discuss something that Ext is doing that you don't agree with, put it in the general discussion forum. That doesn't mean it's a bug.
Jack Slocum
Founder and original developer of Ext JS
Comment | File | Size | Author |
---|---|---|---|
#1 | flag.js_.patch | 1.11 KB | kenorb |
Comments
Comment #1
kenorb commentedAs suggested, I've created following patch.
The patch is for 6.x-2.0-beta5
Comment #2
kenorb commentedWorkaround is to change the order and move ExtJS to the footer.
Comment #3
quicksketchThe excerpt you've quoted does not make sense in this context:
Flag is not using string keys here. It's using numeric indices (as that's the only things Arrays support, as that forum post says a couple of times). I think ExtJS is in the wrong here, but I know it's not the only library that tries to "fix" JavaScript by "enhancing" the language directly. The Prototype language did the same thing, which is one of the main reasons why it "lost" to jQuery in terms of popularity.
In any case, I don't plan on fixing this immediately, but we can fix the problem by using jQuerys $.each() method instead of the for-in JavaScript construct.
Comment #4
joachim commentedComment #5
hestenetComment #6
ivnishDrupal 7 is EOL. Issue will be closed, but patches are still here