Bladeren bron

fixed Array.remove

Nicolas Cannasse 16 jaren geleden
bovenliggende
commit
82537cc1a9
2 gewijzigde bestanden met toevoegingen van 14 en 2 verwijderingen
  1. 1 0
      doc/CHANGES.txt
  2. 13 2
      std/js/Boot.hx

+ 1 - 0
doc/CHANGES.txt

@@ -5,6 +5,7 @@ TODO :
 
 2009-??-??: 2.04
 	flash9 : fixed get_full_path error with -D fdb
+	js : fixed Array.remove on IE
 
 2009-03-22: 2.03
 	optimized Type.enumEq : use index instead of tag comparison for neko/flash9/php

+ 13 - 2
std/js/Boot.hx

@@ -199,12 +199,23 @@ class Boot {
 			Array.prototype.insert = function(i,x) {
 				this.splice(i,0,x);
 			};
-			Array.prototype.remove = function(obj) {
+			Array.prototype.remove = if( Array.prototype.indexOf ) function(obj) {
 				var idx = this.indexOf(obj);
 				if( idx == -1 ) return false;
 				this.splice(idx,1);
 				return true;
-			}
+			} else function(obj) {
+				var i = 0;
+				var l = this.length;
+				while( i < l ) {
+					if( this[i] == obj ) {
+						this.splice(i,1);
+						return true;
+					}
+					i++;
+				}
+				return false;
+			};
 			Array.prototype.iterator = function() {
 				return {
 					cur : 0,