Welcome! Log In Create A New Profile

Advanced

[njs] Fixed property setter lookup.

Dmitry Volyntsev
July 22, 2019 10:22AM
details: https://hg.nginx.org/njs/rev/82c03a8af063
branches:
changeset: 1065:82c03a8af063
user: Artem S. Povalyukhin <artem.povaluhin@gmail.com>
date: Sat Jul 20 13:31:59 2019 +0300
description:
Fixed property setter lookup.

diffstat:

njs/njs_object_property.c | 12 ++++++------
njs/test/njs_unit_test.c | 4 ++++
2 files changed, 10 insertions(+), 6 deletions(-)

diffs (43 lines):

diff -r 97ab91a7c7f5 -r 82c03a8af063 njs/njs_object_property.c
--- a/njs/njs_object_property.c Tue Jul 02 22:24:11 2019 -0400
+++ b/njs/njs_object_property.c Sat Jul 20 13:31:59 2019 +0300
@@ -599,7 +599,12 @@ njs_value_property_set(njs_vm_t *vm, njs
return NXT_ERROR;
}

- } else if (!njs_is_function(&prop->setter)) {
+ } else {
+ if (njs_is_function(&prop->setter)) {
+ return njs_function_call(vm, njs_function(&prop->setter),
+ object, value, 1, &vm->retval);
+ }
+
njs_type_error(vm,
"Cannot set property \"%V\" of %s which has only a getter",
&pq.lhq.key, njs_type_string(object->type));
@@ -623,11 +628,6 @@ njs_value_property_set(njs_vm_t *vm, njs
break;
}

- if (njs_is_function(&prop->setter)) {
- return njs_function_call(vm, njs_function(&prop->setter),
- object, value, 1, &vm->retval);
- }
-
goto found;

case NJS_PROPERTY_REF:
diff -r 97ab91a7c7f5 -r 82c03a8af063 njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c Tue Jul 02 22:24:11 2019 -0400
+++ b/njs/test/njs_unit_test.c Sat Jul 20 13:31:59 2019 +0300
@@ -9629,6 +9629,10 @@ static njs_unit_test_t njs_test[] =
"Object.defineProperty(o, 'a', {get:()=>1}); o.a = 2"),
nxt_string("TypeError: Cannot set property \"a\" of object which has only a getter") },

+ { nxt_string("var o = Object.create(Object.defineProperty({}, 'x', { set: function(v) { this.y = v; }})); "
+ "o.x = 123; Object.getOwnPropertyDescriptor(o, 'y').value"),
+ nxt_string("123") },
+
{ nxt_string("var o = {};"
"Object.defineProperty(o, 'a', { configurable: true, value: 0 });"
"Object.defineProperty(o, 'a', { value: 1 });"
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Fixed property setter lookup.

Dmitry Volyntsev 281 July 22, 2019 10:22AM



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

Online Users

Guests: 235
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready