You are not logged in.
I am working on supporting Xinha in the MyST Blogsite platform and have discovered a compatibility problem between Xinha and some other libraries. The problem has to do with the fact that Xinha is adding methods to the Array prototype. This is a global change that has side effects that can break existing code.
Specifically, adding methods to the Array prototype breaks (i.e., injects new behaviors into) iterations of the form:
for (i in someArray)...
The problem is that the new methods (e.g., append, contains, etc.) added by Xinha are now iterated where they previously were not. One workaround is to rewrite such iterations as:
for (var i=0; i < someArray.length; i++)...
This for does not iterate the Xinha-added methods. BUT... it is not always practical to make such a code change (e.g., when using a third-party, especially for libraries provided in obfuscated form.)
IMO, it would be better for Xinha to not assume it can modify the global Array prototype. Instead, Xinha should either a) implement its additional methods has helper functions in some Xinha namespace; or b) create a new derived Array that contains the additional methods. Either of these aproaches would eliminate Xinha's current global side-effects.
Thoughts?
-- fas
Last edited by faseidl (2009-01-02 01:20:39)
Offline
I agree in principle, a single wrapper function to augment specific objects would be beneficial ( $xjs() for Xinha Javascript or something ), then adjusting the calls to those prototyped methods to use the wrapper. However it could be a big arduous job.
Patches welcome.
James Sleeman
Offline