rtfeldman / seamless-immutable

Immutable data structures for JavaScript which are backwards-compatible with normal JS Arrays and Objects.
BSD 3-Clause "New" or "Revised" License
5.37k stars 195 forks source link

Files not being replaced on a deep merge #265

Open ericdsmith opened 5 years ago

ericdsmith commented 5 years ago

On a deep merge of an Immutable object, properties that have a file are not being replaced. An example of the current behavior:

var oldObj = Immutable({ file: new File([''], 'oldFile') })
var newObj = oldObj.merge({ file: new File([''], 'newFile') }, { deep: true })
console.log(newObj.file.name) // outputs ==> ’oldFile’

I would expect the old file to be replaced with the new file. In looking at the code, the merge function attempts to to merge the two files which fails because Object.getOwnPropertyDescriptor returns undefined for a File’s properties. Updating isMergableObject to check if the object is a File or Blob would fix this issue. Happy to put up a PR if that approach seems reasonable.