#bind is meant to be used to alter function in such way that it will
always be executed within a specified context. Why would you want to
call bind on an object which is not a function?
- kangax
On Mar 21, 8:26 pm, Lei <lei....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi Guys,
>
> I was using prototype 1.5.* on my firefox extension project, and it
> works like a charm. Now due to the changes made in 1.6.*, specifically
> on Function.prototype, the bind method and delay method will throw
> errors.
>
> I looked into the code and here is what I found.
>
> In 1.5.*, the bind function is always only called on a function that
> javascript engine know, while in 1.6.*, the bind is called on a
> variable that could be just an ordinary object. See example below:
>
> 1.5.*
> ------------
> setTimeout(function() { this.respondToReadyState(1) }.bind(this), 10);
> ------------
>
> 1.6.*
> ------------
> var Enumerable = {
> each: function(iterator, context) {
> var index = 0;
> iterator = iterator.bind(context);
> -------------
>
> There is no way for the javascript engine to tell if the iterator in
> this case is a function object or not, so Firefox throws me an error ;-
> (
>
> To reproduce, just add prototype.js inside one of your firefox
> extension, and you will see the error right away.
>
> Can someone please shed some light on how to work around this problem?
>
> Thanks!
>
> Lei
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---