Function.prototype.bind and Function.prototype.prependArg

162 views
Skip to first unread message

Jack Moffitt

unread,
Nov 30, 2010, 1:03:30 PM11/30/10
to strophe
Someone kindly pointed out that Strophe's replacement for bind() is
not actually up to spec. Specifically the real bind() prepends
arguments that are given after the context, and Strophe just ignored
these. Bug here:
https://github.com/metajack/strophejs/issues/closed#issue/14

I've fixed the Strophe version of bind() to be compatible, but I
realized that this duplicates the functionality of prependArg (which
is not a standard function).

Since prependArg was marked as private, I have removed it from Strophe
and also changed the Strophe code which used it to use bind() instead.
(Note that fun.prependArg(foo) is the same as fun.bind(null, foo); ).

If you were using prependArg, you will need to update your code to
use bind(). Please let me know if anyone was actually using this.

It is highly likely that I will move the Function.prototype.bind and
Array.prototype.indexOf to Strophe._bind and Strophe._indexOf so as
not to monkeypatch the VM. This seems like the preferred practice
lately; when I originally wrote Strophe, no such conventions existed
(at least not to my knowledge).

jack.

Reply all
Reply to author
Forward
0 new messages