Skip to content

Don't copy a property which is not a plain object but an object.  #4

@sttk

Description

@sttk

By modification to fix #3, a following bug is included:

function O(v) {
  this.a = { b: { c: v } };
}
var o1 = new O(123);
var o2 = new O(456);
var p1 = { o: o1 };
var p2 = { o: o2 };
copyProps(p1, p2);
console.log(p2.o === o1); // => false, but it should be true!

This bug can be fixed by using isPlainObject to check an empty plain object instead of isObject.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions