Skip to content

Commit

Permalink
Don't use Function.prototype.bind for IE<9, Safari<5.1.
Browse files Browse the repository at this point in the history
Fixes #69.
  • Loading branch information
domenic committed May 16, 2012
1 parent 02241ea commit 63a7afa
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions q.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

1 comment on commit 63a7afa

@domenic
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.