]> git.kaiwu.me - quickjs.git/commitdiff
fixed operation order in Object.prototype.propertyIsEnumerable()
authorFabrice Bellard <fabrice@bellard.org>
Tue, 22 Apr 2025 16:59:21 +0000 (18:59 +0200)
committerFabrice Bellard <fabrice@bellard.org>
Tue, 22 Apr 2025 16:59:21 +0000 (18:59 +0200)
quickjs.c

index 89e85010a5a246e1e742a13675d182589a688697..0268061d4a4c80fefb39d441c03cc5064d702c51 100644 (file)
--- a/quickjs.c
+++ b/quickjs.c
@@ -37312,6 +37312,7 @@ static __exception int JS_ObjectDefineProperties(JSContext *ctx,
     if (JS_IsException(props))
         return -1;
     p = JS_VALUE_GET_OBJ(props);
+    /* XXX: not done in the same order as the spec */
     if (JS_GetOwnPropertyNamesInternal(ctx, &atoms, &len, p, JS_GPN_ENUM_ONLY | JS_GPN_STRING_MASK | JS_GPN_SYMBOL_MASK) < 0)
         goto exception;
     for(i = 0; i < len; i++) {
@@ -38268,17 +38269,17 @@ exception:
 static JSValue js_object_propertyIsEnumerable(JSContext *ctx, JSValueConst this_val,
                                               int argc, JSValueConst *argv)
 {
-    JSValue obj, res = JS_EXCEPTION;
-    JSAtom prop = JS_ATOM_NULL;
+    JSValue obj = JS_UNDEFINED, res = JS_EXCEPTION;
+    JSAtom prop;
     JSPropertyDescriptor desc;
     int has_prop;
 
-    obj = JS_ToObject(ctx, this_val);
-    if (JS_IsException(obj))
-        goto exception;
     prop = JS_ValueToAtom(ctx, argv[0]);
     if (unlikely(prop == JS_ATOM_NULL))
         goto exception;
+    obj = JS_ToObject(ctx, this_val);
+    if (JS_IsException(obj))
+        goto exception;
 
     has_prop = JS_GetOwnPropertyInternal(ctx, &desc, JS_VALUE_GET_OBJ(obj), prop);
     if (has_prop < 0)