immutable-js-oss / immutable-js

Immutable persistent data collections for Javascript which increase efficiency and simplicity.
https://immutable-js-oss.github.io/immutable-js/
MIT License
37 stars 6 forks source link

Unexpected behavior when doing a mergeIn with an empty object/map #138

Open Methuselah96 opened 4 years ago

Methuselah96 commented 4 years ago

From @ztoben on Tue, 04 Jun 2019 17:43:23 GMT

What happened

We ran into a strange behavior when using mergeIn with an empty object.

When doing a mergeIn on any map, if the map being merged in is empty, ie {} or Map({}), then it doesn't seem to get merged at all.

Either this is intended behavior and not documented well, or it seems to be a bug.

How to reproduce

const foo = Map({});
const bar = foo.mergeIn(['baz'], {});
console.log(bar.toJS());

Expected output: {baz: {}}

Actual output: {}

Copied from original issue: https://github.com/immutable-js/immutable-js/issues/1715