intelie / immutable-js-diff

MIT License
260 stars 32 forks source link

Nested objects diff incorrectly #18

Open netogallo opened 7 years ago

netogallo commented 7 years ago

If a record (probably other elements) contains a plain JSON object wich needs a replace operation, it will be replaced by a Immutable map.

const R = Record({test: {wrong: false}})
var patch = diff(R(), R({test: {wrong: true}})
console.log(patch.getIn([0,"value"]).wrong) // prints undefined instead of true

This happens because after computing the patch, Immutable.fromJS() is called which interprets the plain objects as immutable maps. The fix is simple and I can send you a pull request. I was just wondering if this was intentional or not.