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 screenshots:
Only local images are allowed.
Only local images are allowed.

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

CommentFileSizeAuthor
#1 flag.js_.patch1.11 KBkenorb

Comments

kenorb’s picture

Version: 6.x-2.x-dev » 6.x-2.0-beta5
StatusFileSize
new1.11 KB

As suggested, I've created following patch.
The patch is for 6.x-2.0-beta5

kenorb’s picture

Status: Active » Needs review

Workaround is to change the order and move ExtJS to the footer.

quicksketch’s picture

Title: Conflict with ExtJS framework: Object function has no method 'match' » Make compatible with ExtJS framework: Object function has no method 'match'
Category: bug » task
Status: Needs review » Needs work

The excerpt you've quoted does not make sense in this context:

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?

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.

joachim’s picture

Version: 6.x-2.0-beta5 » 7.x-3.x-dev
Status: Needs work » Postponed
hestenet’s picture

Issue summary: View changes
ivnish’s picture

Status: Postponed » Closed (outdated)

Drupal 7 is EOL. Issue will be closed, but patches are still here

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.