fixed operation order in Object.prototype.propertyIsEnumerable()

This commit is contained in:
Fabrice Bellard 2025-04-22 18:59:21 +02:00
parent 5afd0eb37b
commit 1e958abcd8

View File

@ -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)