Closed seva-luchianov closed 5 years ago
Looks like a bug caused by this line: https://github.com/TehShrike/deepmerge/blob/8209fc671a07b73ace6141fa743cae28f3e2481e/index.js#L47
It's checking if the value in the target is falsey, when it should be checking to see if the property doesn't exist in the target.
It would be great if someone could contribute a failing test.
The new test should probably use isMergeableObject: () => true
and a customMerge
function that asserts that it is called when asked to merge({ a: false }, { a: false })
Actually, I think this could be fixed by a tweak to #164...
A failing test would still be nice though.
I assume this will also fail for other falsey things like ""
and 0
?
Yup. It's a pretty dumb bug.
I would like to utilize deepmerge to combine two objects that only have boolean keys in a way that keeps all booleans that were true in the destination object to remain true after the merge. Code is below:
What I've found is that any boolean keys of the destination object that are false before the merge are never logged in the customMerge function, and end up as
{}
after the merge is complete. Here is the output after executing this code:Expected output is:
Using deepmerge 4.1.1 and is-mergeable-object 1.1.1