Skip to content

Commit d40f4a5

Browse files
Making sure conform ECMAScript 2026 20.1.3.2, 20.1.3.3 and 20.1.3.4.
1 parent 69514db commit d40f4a5

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

src/njs_object.c

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2596,14 +2596,6 @@ njs_object_prototype_has_own_property(njs_vm_t *vm, njs_value_t *args,
25962596
njs_value_t *value, *property, lvalue;
25972597
njs_property_query_t pq;
25982598

2599-
value = njs_argument(args, 0);
2600-
2601-
if (njs_is_null_or_undefined(value)) {
2602-
njs_type_error(vm, "cannot convert %s argument to object",
2603-
njs_type_string(value->type));
2604-
return NJS_ERROR;
2605-
}
2606-
26072599
property = njs_lvalue_arg(&lvalue, args, nargs, 1);
26082600

26092601
if (njs_slow_path(!njs_is_key(property))) {
@@ -2613,6 +2605,14 @@ njs_object_prototype_has_own_property(njs_vm_t *vm, njs_value_t *args,
26132605
}
26142606
}
26152607

2608+
value = njs_argument(args, 0);
2609+
2610+
if (njs_is_null_or_undefined(value)) {
2611+
njs_type_error(vm, "cannot convert %s argument to object",
2612+
njs_type_string(value->type));
2613+
return NJS_ERROR;
2614+
}
2615+
26162616
njs_property_query_init(&pq, NJS_PROPERTY_QUERY_GET, 1);
26172617

26182618
ret = njs_property_query_val(vm, &pq, value, property);
@@ -2642,14 +2642,6 @@ njs_object_prototype_prop_is_enumerable(njs_vm_t *vm, njs_value_t *args,
26422642
njs_object_prop_t *prop;
26432643
njs_property_query_t pq;
26442644

2645-
value = njs_argument(args, 0);
2646-
2647-
if (njs_is_null_or_undefined(value)) {
2648-
njs_type_error(vm, "cannot convert %s argument to object",
2649-
njs_type_string(value->type));
2650-
return NJS_ERROR;
2651-
}
2652-
26532645
property = njs_lvalue_arg(&lvalue, args, nargs, 1);
26542646

26552647
if (njs_slow_path(!njs_is_key(property))) {
@@ -2659,6 +2651,14 @@ njs_object_prototype_prop_is_enumerable(njs_vm_t *vm, njs_value_t *args,
26592651
}
26602652
}
26612653

2654+
value = njs_argument(args, 0);
2655+
2656+
if (njs_is_null_or_undefined(value)) {
2657+
njs_type_error(vm, "cannot convert %s argument to object",
2658+
njs_type_string(value->type));
2659+
return NJS_ERROR;
2660+
}
2661+
26622662
njs_property_query_init(&pq, NJS_PROPERTY_QUERY_GET, 1);
26632663

26642664
ret = njs_property_query_val(vm, &pq, value, property);
@@ -2689,15 +2689,20 @@ njs_object_prototype_is_prototype_of(njs_vm_t *vm, njs_value_t *args,
26892689
njs_value_t *prototype, *value;
26902690
njs_object_t *object, *proto;
26912691

2692+
value = njs_arg(args, nargs, 1);
2693+
2694+
if (njs_slow_path(!njs_is_object(value))) {
2695+
goto ret_false;
2696+
}
2697+
26922698
if (njs_slow_path(njs_is_null_or_undefined(njs_argument(args, 0)))) {
26932699
njs_type_error(vm, "cannot convert undefined to object");
26942700
return NJS_ERROR;
26952701
}
26962702

26972703
prototype = &args[0];
2698-
value = njs_arg(args, nargs, 1);
26992704

2700-
if (njs_is_object(prototype) && njs_is_object(value)) {
2705+
if (njs_is_object(prototype)) {
27012706
proto = njs_object(prototype);
27022707
object = njs_object(value);
27032708

@@ -2712,6 +2717,8 @@ njs_object_prototype_is_prototype_of(njs_vm_t *vm, njs_value_t *args,
27122717
} while (object != NULL);
27132718
}
27142719

2720+
ret_false:
2721+
27152722
njs_set_boolean(retval, 0);
27162723

27172724
return NJS_OK;

0 commit comments

Comments
 (0)