Permalink
Browse files

Don't use `Function.prototype.bind` for IE<9, Safari<5.1.

Fixes #69.
  • Loading branch information...
1 parent 02241ea commit 63a7afa644e5f17086983a3f76ef2ee31553921c @domenic domenic committed May 16, 2012
Showing with 8 additions and 2 deletions.
  1. +8 −2 q.js
View
@@ -1389,8 +1389,14 @@ function ncall(callback, thisp /*, ...args*/) {
exports.nbind = nbind;
function nbind(callback /* thisp, ...args*/) {
if (arguments.length > 1) {
- var args = array_slice(arguments, 1);
- callback = callback.bind.apply(callback, args);
+ var thisp = arguments[1];
+ var args = array_slice(arguments, 2);
+
+ var originalCallback = callback;
+ callback = function () {
+ var combinedArgs = args.concat(array_slice(arguments));
+ return originalCallback.apply(thisp, combinedArgs);
+ };
}
return function () {
var deferred = defer();

1 comment on commit 63a7afa

@domenic
Collaborator

For any passers-by: the commit message should in fact read Safari<=5.1. Yep, they still don't have bind.

Please sign in to comment.