Closed
Description
The current implementation of applyChange()
copies a reference to the change object's rhs
property in line 379. Any changes to the target object also changes the change object afterwards. Example:
const target = {};
const change1 = { kind: "N": path: ["foo"], rhs: {} };
const change2 = { kind: "N": path: ["foo", "bar"], rhs: "bug" };
applyChange(target, true, change1);
applyChange(target, true, change2);
console.log(change1.rhs.bar) // prints "bug"
I am currently working around this issue by deep-cloning my change objects before applying them.
I would issue a pull request using clone-deep, but I'm not sure if that is in the best interest of this library, as it has no dependencies at the moment.
Metadata
Metadata
Assignees
Labels
No labels