There is a problem brewing for people that wish to use more than one Ajax library in the same page. It ought to be easy, but it's not...
In the mean time the there is the very real danger of mid air collisions.
DWR has a $ function, copied from Prototype. So do Atlas and many other frameworks. Alex Russell says it is a very frequently requested feature for Dojo.
The $ function is the only function in DWR that isn't in an object based namespace. I'm not keen on it for this reason, but it is very useful: document.getElementById() is just such a mouthful.
But there is a problem:
- When Prototype changes their definition of $, what is everyone else supposed to do?
- What happens when Prototype's $ gets over written by a $ from another library without the new features?
- What happens if another library want to add some feature that Prototype doesn't pick up?
- What happens when to implementations of $ evolve in incompatible directions?
So here is my proposal:
Ajax library authors except Prototype should get together to define $ to mean basically document.getElementById() and nothing more. Each should do as DWR does and check for the existence of $ before defining it. Prototype on the other hand should not do the same check. Ever. Prototype should ensure that it's definition of $ is always a strict superset of the 'standard' definition.
DWR can be used with any version of Prototype because if Prototype gets declared first, it defines $ in it's superset form, and then as DWR is declared, it notices and does not alter the superset definition. If however DWR gets defined first, it will define $, however Prototype will overwrite the subset definition with it's superset definition.