Skip to content

Commit

Permalink
Fixed constructor property of an iterator object.
Browse files Browse the repository at this point in the history
This fixes #737 issue on Github.
  • Loading branch information
xeioex committed Jul 2, 2024
1 parent 89aca30 commit 7f55a51
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/njs_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -2168,6 +2168,10 @@ njs_object_prototype_create_constructor(njs_vm_t *vm, njs_object_prop_t *prop,

found:

if (njs_flathsh_is_empty(&vm->constructors[index].object.shared_hash)) {
index = NJS_OBJ_TYPE_OBJECT;
}

njs_set_function(&constructor, &njs_vm_ctor(vm, index));
setval = &constructor;

Expand Down
3 changes: 3 additions & 0 deletions src/test/njs_unit_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -7450,6 +7450,9 @@ static njs_unit_test_t njs_test[] =
"[i.next(), i.next(), i.next(), i.next()].map((x) => x.value)"),
njs_str("1,2,3,") },

{ njs_str("[].values().constructor()"),
njs_str("[object Object]") },

{ njs_str("var a = [], i = a.values();"
"a.push(1); a.push(2); a.push(3);"
"[i.next(), i.next(), i.next(), i.next()].map((x) => x.value)"),
Expand Down

0 comments on commit 7f55a51

Please sign in to comment.