Background: As is well known, some code is broken by the useful
extensions that prototype.js adds to the Array prototype.  In
particular the "for (var x in array)" idiom that some libraries like
to use.
(Due to design flaw in Javascript itself, the for loop iterates not
only over the elements of the array but also the non-built in
functions added by prototype.  This breaks code that doesn't expect
functions.)

I'm happy to rewrite my code to use the prototype idioms, but I can't
rewrite every library I might want to call that uses the broken idiom.

It's a fairly simple matter to modify prototype.js so that, rather
than modifying the Array.prototype, individual arrays are extended
explicitly by the $A function only when I want them to.  I get the
extended array behavior when I want it, and can use vanilla arrays
when I call out to third party code.

It seems like enough people might want this behavior that it couldbe
added as an option on the core prototype.js-- add some sort of switch
so that the auto-extend behavior on Arrays can be turned off in favor
of the explicit model described here.




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to