Commentag plugin now compatible with Prototype.js lib running in parallel
Strangely enough, the Commentag plugin was not working on Nellio.com.
It produced some strange javascript outputs.
Digging into the problem showed that jQuery is not a friend of Prototype (two Javascript librairies).
So, I’m now running jQuery in noConflict() mode.
Besides, I also had to change
for (t in tags[])
to something like
for (t=0;t < tags.length;t++)
Because it looks like Prototype is adding some helpers to manipulate arrays which causes a for each loop to actually call these helpers. Which is really bad.
So now, it is all fixed.
Oh, btw, no one has got to update their commentag plugin ![]()
If you had the problem and turned off the commentag plugin, just re active it and it will work like a charm.
Don't forget to give us your feedback
April 22nd, 2008 at 3:53 pm
In fact prototypejs lib extends all arrays with properties which are not set to non-enumerable. That’s the reason why all “for … in” are broken.
From the Prototype website http://www.prototypejs.org/api/array
By default, the prototype and the length properties are so marked, which prevents you from enumerating over array methods when using for…in. This comfort led developers to use for…in as a shortcut for indexing loops, when it is not its actual purpose.
However, Prototype has no way to mark the methods it adds to Array.prototype as non-enumerable. Therefore, using for…in on arrays when using Prototype will enumerate all extended methods as well, such as those coming from the Enumerable module, and those Prototype puts in the Array namespace (described in this section, and listed further below).