-
Notifications
You must be signed in to change notification settings - Fork 218
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
customMerge should probably be called when cloning mergeable values #176
Comments
This is expected behavior. The merge function is only called if Line 66 in d1ae60f
|
…erged Also reverse the if check so you don't have to think your way through two negations and an OR Inspired by #176
I just published 4.2.2 which makes it so that Line 66 in e9c9fec
I also flipped around the if/else code blocks to make the conditional a lot easier to read. |
I see, thanks for clearing that up. |
That's what deepmerge does now: Lines 66 to 70 in e9c9fec
|
I'm not sure I understand. In my example, the |
Oh I'm sorry, I misread – you have the attribute on the target, but not on the source. So, in your case, it is actually going down the Lines 7 to 11 in e9c9fec
And since Lines 3 to 5 in e9c9fec
Maybe that should be getMergeFunction(key, options)(emptyTarget(value), value, options) instead of deepmerge(emptyTarget(value), value, options) ? |
Right, so it's overwriting the target boolean key with |
(Sorry for the early comment/accidental close there, I accidentally hit Cmd+Enter. I've edited that comment) |
gotcha, i just reread that comment. I guess |
Out of the box, deepmerge only copies properties/elements of objects and arrays. And if an empty something isn't an array, it must be an object. We could talk about making it possible to pass in a custom |
Both seem like good options! |
Calling the If you want to open a PR with a failing test, that would be appreciated. |
Just made the PR |
Hello, back with a similar bug to my previous issue. I updated to 4.2.1 and the boolean merge was indeed fixed, but it is broken when applied alongside other object types. For example:
will log:
seems like the boolean keys aren't getting logged in the custom merge function.
This is the base case, though it also doesn't work in tandem with arrayMerge, which is my current use-case:
will log:
Thanks for the quick response to that previous issue!
Using deepmerge 4.2.1 and is-mergeable-object 1.1.1
The text was updated successfully, but these errors were encountered: