Welcome! Log In Create A New Profile

Advanced

[njs] Fixed constructor property of an iterator object.

Anonymous User
July 01, 2024 10:36PM
details: https://github.com/nginx/njs/commit/7f55a51f23113e3fc8a57d2598f3b87101098bb2
branches: master
commit: 7f55a51f23113e3fc8a57d2598f3b87101098bb2
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Wed, 26 Jun 2024 18:50:43 -0700
description:
Fixed constructor property of an iterator object.

This fixes #737 issue on Github.

---
src/njs_object.c | 4 ++++
src/test/njs_unit_test.c | 3 +++
2 files changed, 7 insertions(+)

diff --git a/src/njs_object.c b/src/njs_object.c
index 5a5970c9..f2aa46a3 100644
--- a/src/njs_object.c
+++ b/src/njs_object.c
@@ -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;

diff --git a/src/test/njs_unit_test.c b/src/test/njs_unit_test.c
index 96c922bc..530cf6ff 100644
--- a/src/test/njs_unit_test.c
+++ b/src/test/njs_unit_test.c
@@ -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)"),
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Fixed constructor property of an iterator object.

Anonymous User 127 July 01, 2024 10:36PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 180
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready