Skip to content

Commit 5729dd8

Browse files
authored
Object.assign should copy undefined values (#4688)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg [email protected]
1 parent e8ed543 commit 5729dd8

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

jerry-core/ecma/builtin-objects/ecma-builtin-object.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,9 +1107,7 @@ ecma_builtin_object_object_assign (ecma_object_t *target_p, /**< target object *
11071107
}
11081108

11091109
/* 5.c.iii */
1110-
if ((prop_desc.flags & JERRY_PROP_IS_ENUMERABLE)
1111-
&& (((prop_desc.flags & JERRY_PROP_IS_VALUE_DEFINED) && !ecma_is_value_undefined (prop_desc.value))
1112-
|| (prop_desc.flags & JERRY_PROP_IS_GET_DEFINED)))
1110+
if (prop_desc.flags & JERRY_PROP_IS_ENUMERABLE)
11131111
{
11141112
/* 5.c.iii.1 */
11151113
ecma_value_t prop_value = ecma_op_object_get (from_obj_p, property_name_p);

tests/jerry/es.next/object-assign.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,10 @@ var result = Object.assign ({}, obj);
165165
assert (result[foo] == 7);
166166
assert (result[asd] == 8);
167167
assert (result[bar] == 9);
168+
169+
obj = {}
170+
assert(Object.assign(obj, { a:1, b:undefined, get c() {}, set d(v) {}}) == obj);
171+
assert(Object.getOwnPropertyDescriptor(obj, "a").enumerable);
172+
assert(Object.getOwnPropertyDescriptor(obj, "b").enumerable);
173+
assert(Object.getOwnPropertyDescriptor(obj, "c").enumerable);
174+
assert(Object.getOwnPropertyDescriptor(obj, "d").enumerable);

0 commit comments

Comments
 (0)