Skip to content
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

Fixed finalizing array #78

Merged
merged 3 commits into from
Jan 24, 2018
Merged

Fixed finalizing array #78

merged 3 commits into from
Jan 24, 2018

Conversation

iruca3
Copy link
Contributor

@iruca3 iruca3 commented Jan 23, 2018

I got error on this test case. (see the diff)
I could not figure out why this is caused.
It seems some copy of array element is a Proxy.
Therefore, I did finalizing copy on finalizeArray in any case.

I don't know the same thing is needed on finalizeObject.
Would you review my code please?

I'm very glad to meet such a wonderful library :)

addition

I found another case below:

const base = {
    arr: [{count: 1}, {count: 2}]
}
const result = produce(base, draft => {
    draft.arr = [
        draft.arr[1]
    ]
    draft.arr[0].count = 1
})
expect(result).toEqual({
    arr: [{count: 1}]
})

This also causes an error.
Shouldn't I use the draft object on new array or object....?

@coveralls
Copy link

coveralls commented Jan 23, 2018

Coverage Status

Coverage decreased (-0.02%) to 98.588% when pulling 9d54d64 on iruca3:fix/finalize into 7290670 on mweststrate:master.

@mweststrate mweststrate merged commit 9d54d64 into immerjs:master Jan 24, 2018
@mweststrate
Copy link
Collaborator

Thanks! I merged it, but implemented it a bit differently as there was another underlying issue. But thanks for finding and reproducing the bug!

@mweststrate
Copy link
Collaborator

Will release soon as 8.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants