소스 검색

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

Vladislav Folts 11 년 전
부모
커밋
0d6b794404
1개의 변경된 파일10개의 추가작업 그리고 0개의 파일을 삭제
  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(){