View Full Version : Name Collision with PrototypeJS on Function.prototype.defer

21 Nov 2009, 4:56 AM
I'm sure this fact is probably already known but there is a naming collision on Function.prototype.defer when ExtJS is used in combination with PrototypeJS.

Prototype defines the method differently than ExtJS and it took me half a day of swearing at my computer to understand this problem because I was expecting the fault to be in my code and not the Prototype/Ext libraries. Consider this code:

//To call a function "deferred" until the processor is idle with a defined scope and array arguments with arbitrary length, the syntax is this:
fn.defer.apply(fn.bind(scope), args || []);
//To do the same thing once you introduce ext-prototype-adapter.js, the syntax changes to this:
fn.defer.apply(fn.bind(scope), [0.001, scope, args || []]);

The name collision doesn't matter once you figure out it exists, but it's very confusing until you do, so if there's any scope for renaming Function.prototype.defer in ExtJS in the future, I vote in favour of doing so.