From 82971d7cd1f71e7cbf2ba3e43ffaf6f878a3fe12 Mon Sep 17 00:00:00 2001 From: Takuto Wada Date: Mon, 23 Dec 2013 07:06:03 +0900 Subject: [PATCH] Remove private clone of Function#bind for old browsers (please use es5-shim). --- lib/empower.js | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/lib/empower.js b/lib/empower.js index 238a330..3e51ca2 100644 --- a/lib/empower.js +++ b/lib/empower.js @@ -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); } }); @@ -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;