This project is archived and is in readonly mode.

#963 ✓duplicate
AJ Palkovic

Function.prototype.bind broken in Chrome beta

Reported by AJ Palkovic | August 25th, 2010 @ 06:47 AM

So, in Chrome 6, google has added its own implementation of the Function.prototype.bind method. Mootools also defines this method, but, it checks if Function.prototype.bind exists, and if it does, it will just use that one, because in theory the browser's native implementation is faster.

The problem, is that the two methods have different signatures.
Both methods allow you to pass additional arguments to the 'bound' function. Mootools allows you to pass them as an array and then at runtime they will be translated so argument1 is the first element of the array and so on. The chrome implementation just wants you to pass them as extra parameters to bind.

The problem here, is that any site that was built using the original Mootools method signature will appear to be broken if a user upgrades to Chrome 6.
A quick fix would be to add this after the call to Function.implement:
Function.prototype.bind = function(bind, args) { return this.create({bind: bind, arguments: args}); }

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

People watching this ticket

Pages