Skip to content

Commit

Permalink
Remove private clone of Function#bind for old browsers (please use es…
Browse files Browse the repository at this point in the history
…5-shim).
  • Loading branch information
twada committed Dec 22, 2013
1 parent 9f6240a commit 82971d7
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions lib/empower.js
Expand Up @@ -120,12 +120,12 @@

config.targetMethods.oneArg.forEach(function (methodName) {
if (typeof target[methodName] === 'function') {
enhancement[methodName] = decorateOneArg(bind(target[methodName], target), formatter);
enhancement[methodName] = decorateOneArg(target[methodName].bind(target), formatter);
}
});
config.targetMethods.twoArgs.forEach(function (methodName) {
if (typeof target[methodName] === 'function') {
enhancement[methodName] = decorateTwoArgs(bind(target[methodName], target), formatter);
enhancement[methodName] = decorateTwoArgs(target[methodName].bind(target), formatter);
}
});

Expand Down Expand Up @@ -204,24 +204,6 @@
}


// borrowed from https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Function/bind
function bind (aFunction, oThis) {
if (typeof aFunction !== 'function') {
throw new TypeError('bind - what is trying to be bound is not callable');
}
var aArgs = Array.prototype.slice.call(arguments, 2),
fToBind = aFunction,
NOP = function () {},
fBound = function () {
return fToBind.apply(((aFunction instanceof NOP) && oThis) ? aFunction : oThis,
aArgs.concat(Array.prototype.slice.call(arguments)));
};
NOP.prototype = aFunction.prototype;
fBound.prototype = new NOP();
return fBound;
}


// using returnExports UMD pattern with substack pattern
empower.defaultOptions = defaultOptions;
return empower;
Expand Down

0 comments on commit 82971d7

Please sign in to comment.