Explorar o código

Emulate Function.prototype.bind if not supported by JS host.

Vladislav Folts %!s(int64=11) %!d(string=hai) anos
pai
achega
1f6eb15a46
Modificáronse 1 ficheiros con 10 adicións e 0 borrados
  1. 10 0
      src/rtl.js

+ 10 - 0
src/rtl.js

@@ -9,6 +9,16 @@ if (!Array.prototype.indexOf)
         return -1;
     };
 
+// support Function.bind
+if (!Function.prototype.bind)
+    Function.prototype.bind = function(thisArg){
+        var self = this;
+        var bindArgs = Array.prototype.slice.call(arguments, 1);
+        return function(){
+            return self.apply(thisArg, bindArgs.concat(Array.prototype.slice.call(arguments)));
+        };
+    };
+
 function Class(){}
 Class.extend = function extend(methods){
         function Type(){