-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
current mutates the original objects unexpectedly #51
Comments
hi @francescotescari, based on your previous PR, indeed comparing the values after traversal can solve these two issue. Regarding the second use case, does it not meet your expectations? The second use case should be like this: it('nested drafts work after current', () => {
const base = { k1: {}, k2: {} };
const result = create(base, (draft) => {
const obj = { x: draft.k2 };
draft.k1 = obj;
// current(draft); // try to comment me
obj.x.abc = 100;
draft.k2.def = 200;
});
expect(result.k1.x).toBe(result.k2);
expect(result).toEqual({
k1: { x: { abc: 100, def: 200 } },
k2: { abc: 100, def: 200 },
});
}); |
Indeed, the failing test is with |
I completely agree. This issue has been fixed in v1.0.8. |
Hello!
There is a new bug in the current coming from this PR that actually changes the original objects unexpectedly, breaking:
Here are two failing tests:
The first should be solvable by not assigning the value to the parent if the
getCurrent
(child value) has same identity as the child value (or if the object is frozen).For the second one, I don't see ways of escaping the shallow copy.
The text was updated successfully, but these errors were encountered: