Object.assign should copy undefined values (#4688)

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2021-06-10 10:59:54 +02:00
committed by GitHub
parent e8ed543677
commit 5729dd8cec
2 changed files with 8 additions and 3 deletions
@@ -1107,9 +1107,7 @@ ecma_builtin_object_object_assign (ecma_object_t *target_p, /**< target object *
}
/* 5.c.iii */
if ((prop_desc.flags & JERRY_PROP_IS_ENUMERABLE)
&& (((prop_desc.flags & JERRY_PROP_IS_VALUE_DEFINED) && !ecma_is_value_undefined (prop_desc.value))
|| (prop_desc.flags & JERRY_PROP_IS_GET_DEFINED)))
if (prop_desc.flags & JERRY_PROP_IS_ENUMERABLE)
{
/* 5.c.iii.1 */
ecma_value_t prop_value = ecma_op_object_get (from_obj_p, property_name_p);
+7
View File
@@ -165,3 +165,10 @@ var result = Object.assign ({}, obj);
assert (result[foo] == 7);
assert (result[asd] == 8);
assert (result[bar] == 9);
obj = {}
assert(Object.assign(obj, { a:1, b:undefined, get c() {}, set d(v) {}}) == obj);
assert(Object.getOwnPropertyDescriptor(obj, "a").enumerable);
assert(Object.getOwnPropertyDescriptor(obj, "b").enumerable);
assert(Object.getOwnPropertyDescriptor(obj, "c").enumerable);
assert(Object.getOwnPropertyDescriptor(obj, "d").enumerable);