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:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user