-
Notifications
You must be signed in to change notification settings - Fork 903
Closed
Labels
Ecma IncompatibilityIssues about Rhino being incompatible with the EcmaScript specIssues about Rhino being incompatible with the EcmaScript specbugIssues considered a bugIssues considered a buggood first issueGreat place to start if you're looking to start an open source "resume"Great place to start if you're looking to start an open source "resume"
Milestone
Description
Hi! It looks like Object.assign() should copy undefined properties:
console.log(Object.assign({"a":undefined}, {"b":undefined}))
Object { a: undefined, b: undefined }
However, the Rhino code is skipping undefined values:
case ConstructorId_assign:
{
if (args.length < 1) {
throw ScriptRuntime.typeError1("msg.incompat.call", "assign");
}
Scriptable targetObj = ScriptRuntime.toObject(cx, thisObj, args[0]);
for (int i = 1; i < args.length; i++) {
if ((args[i] == null) || Undefined.isUndefined(args[i])) {
continue;
}
Scriptable sourceObj = ScriptRuntime.toObject(cx, thisObj, args[i]);
Object[] ids = sourceObj.getIds();
for (Object key : ids) {
if (key instanceof String) {
Object val = sourceObj.get((String) key, sourceObj);
if ((val != Scriptable.NOT_FOUND) && !Undefined.isUndefined(val)) { // <=== HERE
targetObj.put((String) key, targetObj, val);
}
} else if (key instanceof Number) {
int ii = ScriptRuntime.toInt32(key);
Object val = sourceObj.get(ii, sourceObj);
if ((val != Scriptable.NOT_FOUND) && !Undefined.isUndefined(val)) { // <=== AND HERE
targetObj.put(ii, targetObj, val);
}
}
}
}
return targetObj;
}
Is there a reason for those !Undefined.isUndefined(val) checks?
Thanks!
Metadata
Metadata
Assignees
Labels
Ecma IncompatibilityIssues about Rhino being incompatible with the EcmaScript specIssues about Rhino being incompatible with the EcmaScript specbugIssues considered a bugIssues considered a buggood first issueGreat place to start if you're looking to start an open source "resume"Great place to start if you're looking to start an open source "resume"