浏览代码

Fix hasField (js)

Pascal Peridont 19 年之前
父节点
当前提交
a98b95220c
共有 1 个文件被更改,包括 10 次插入5 次删除
  1. 10 5
      std/Reflect.hx

+ 10 - 5
std/Reflect.hx

@@ -188,16 +188,21 @@ class Reflect {
 		Tells if an object has a field set. This doesn't take into account the object prototype (class methods).
 	**/
 	public static function hasField( o : Dynamic, field : String ) : Bool {
-		return untyped
+		untyped{
 		#if flash
-			this.hasOwnProperty.call(o,field)
+			return this.hasOwnProperty.call(o,field);
 		#else js
-			o.hasOwnProperty(field)
+			if( o.hasOwnProperty != null )
+				return o.hasOwnProperty(field);
+			var arr = fields(o);
+			for( t in arr.iterator() )
+				if( t == field ) return true;
+			return false;
 		#else neko
-			__dollar__typeof(o) == __dollar__tobject && __dollar__objfield(o,__dollar__hash(field.__s))
+			return __dollar__typeof(o) == __dollar__tobject && __dollar__objfield(o,__dollar__hash(field.__s));
 		#else error
 		#end
-			;
+		}
 	}
 
 	/**