Browse Source

[Js] [Swf8] filter __id__ in Reflect.fields

Simon Krajewski 12 years ago
parent
commit
92c9c22dc0

+ 1 - 1
std/flash8/_std/Reflect.hx

@@ -68,7 +68,7 @@
 		var a : Array<String> = __keys__(o);
 		var i = 0;
 		while( i < a.length ) {
-			if( !a["hasOwnProperty"]["call"](o,a[i]) )
+			if( a[i] == "__id__" || !a["hasOwnProperty"]["call"](o,a[i]) )
 				a.splice(i,1);
 			else
 				++i;

+ 1 - 1
std/js/_std/Reflect.hx

@@ -59,7 +59,7 @@
 		if (o != null) untyped {
 			var hasOwnProperty = __js__('Object').prototype.hasOwnProperty;
 			__js__("for( var f in o ) {");
-			if( hasOwnProperty.call(o, f) ) a.push(f);
+			if( f != "__id__" && hasOwnProperty.call(o, f) ) a.push(f);
 			__js__("}");
 		}
 		return a;

+ 6 - 0
tests/unit/unitstd/haxe/ds/ObjectMap.unit.hx

@@ -19,6 +19,12 @@ o.exists(k1) == true;
 o.exists(k2) == true;
 o.exists(k3) == true;
 
+// the __id__ field should not appear in Reflect.fields
+#if (js || flash8)
+var fields = Reflect.fields(k1);
+fields == ["i"];
+#end
+
 // get
 o.get(k3) == "7";
 o.get(k2) == "8";