Closed (fixed)
Project:
Drupal core
Version:
5.x-dev
Component:
forms system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
2 Feb 2006 at 11:40 UTC
Updated:
3 Apr 2011 at 16:45 UTC
Jump to comment: Most recent file
Comments
Comment #1
jjeff commentedInteresting. I will look into this.
-Jeff
Comment #2
yched commentedChanging title and project : In fact, the bug is not related to the s/p ajax module itself, but to the presence of the Prototype library itself.
I'll try to use the JS debugger to see what's happening really...
Comment #3
yched commentedOkay, here's what I (sort of) understood :
Prototype adds a lot of methods (iterators, helper functions...) to a lot of objects (including arrays)
A side effect is that when you walk an array with a loop like :
you first catch the "regular' elements of the array, and then you catch these Prototype-added methods.
So the (simplified) code in autocomplete.js :
raises an error when it calls the (non existing) 'split' method of these extra elements (which are functions and not strings)
I just replaced
with
I'm no JS expert, so there might be more elegant workarounds, but this does the trick.
(It seems to me that no other drupal js code is impacted, but that might need double-checking)
Comment #4
yched commentedforgot to update the status
Comment #5
markus_petrux commentedI was also a "victim" of prototype.js' method of overriding javascript core objects (Array in this case) with one of my phpBB MODs:
http://forums.phpmix.org/viewtopic.php?t=1014
As far as we saw in that topic, the problem seems to affect MSIE only (a browser bug maybe).
I do not use prototype.js myself, but I believe yched's fix would workaround the problem.
Comment #6
yched commentedWell, the issue I'm dealing with did affect Firefox (1.5/win) - I didn't check for IE or other browsers.
The patch has been tested to work on both FF and IE6.
As it is outlined in the posts you link to, we're not talking about a drupal bug, but rather about allowing the use of a very useful yet quite intrusive external lib.
I'm aware that a 'won't fix' would be tempting for core devs here, Then again, the workaround is so simple...
Comment #7
m3avrck commentedyched, great find! Although the code needs some stylistic changes, I see no reason this can't be committed. Switching from a foreach() to a for() with a count is identical and IIRC, should be a tad bit faster.
Clean up the spacing in the patch and this one should get in.
Comment #8
yched commentedPatch with clean spaces.
Apparently drupal js files do not currently follow a strict convention on the presence of the "var" keyword in
for (var i = 0; ...I chose to include one...
Comment #9
chx commentednicely caught.
Comment #10
markus_petrux commentedJust wanted to add (in case prototype.js coders read this) is that they ought to think about not overriding javascript core objects.
Main reason is such technique is intrusive and prone to conflicts. It happens very often that people use a mixture of javascript snippets in their pages, so some could implement different functions with the same name, hence breaking something here or there, sometimes very difficult to catch. Rather than implementing core extensions via javascript prototype they could create standalone functions.
Probably people should not mix different javascript libraries in the same page, however there are lots of little snippets that could still coexist with frameworks such as prototype.js, if non intrusive techniques were used.
Not sure how prototype.js deals with support, but it would be nice to report these conflicts to them too.
Comment #11
killes@www.drop.org commentedfrom the description it sounds to me as if this were a prototype.js bug rather than a Drupal bug. Anyway, I need a voe from our resident JS gurus before committing this.
Comment #12
killes@www.drop.org commented17:07 < chx> killes: it's not just Prototype that fucks this up but various other tools
applied.
Comment #13
(not verified) commentedComment #14
c960657 commentedJust for the record: This was broken in #57415: Remove drupal_implode_autocomplete(). The regression is being fixed in #784670: autocomplete.js can iterate over functions in Array objects.