Kaynağa Gözat

support IE8 (default browser for Windows XP)

Vladislav Folts 11 yıl önce
ebeveyn
işleme
e641094275
3 değiştirilmiş dosya ile 38 ekleme ve 1 silme
  1. 14 0
      src/errors.js
  2. 9 0
      src/rtl.js
  3. 15 1
      test/test_unit.html

+ 14 - 0
src/errors.js

@@ -1,6 +1,20 @@
+"use strict";
+/*
+do not use Class here - IE8 does not understande overloeded toString method.
+
 var Class = require("rtl.js").Class;
 
 exports.Error = Class.extend({
 	init: function CompileError(msg) {this.__msg = msg;},
 	toString: function(){return this.__msg;}
 });
+*/
+function CompileError(msg){
+    this.__msg = msg;
+}
+
+CompileError.prototype.toString = function(){
+    return this.__msg;
+};
+
+exports.Error = CompileError;

+ 9 - 0
src/rtl.js

@@ -1,5 +1,14 @@
 "use strict";
 
+// support IE8
+if (!Array.prototype.indexOf)
+    Array.prototype.indexOf = function(x){
+        for(var i = 0; i < this.length; ++i)
+            if (this[i] === x)
+                return i;
+        return -1;
+    };
+
 function Class(){}
 Class.extend = function extend(methods){
         function Type(){

+ 15 - 1
test/test_unit.html

@@ -1,4 +1,18 @@
 <!DOCTYPE html>
 <html>
-    <script src="test_unit_browser.js"></script>
+<body>
+
+<script>
+    var console = {
+        log: function(s){
+            var t = document.createTextNode(s);
+            document.body.appendChild(t);
+            document.body.appendChild(document.createElement("br"));
+        }
+    };
+</script>
+
+<script src="test_unit_browser.js"></script>
+
+</body>
 </html>