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.36k stars 194 forks source link

`merge` ignores Symbols contrary to `set` #189

Open holyjak opened 7 years ago

holyjak commented 7 years ago

Using Immutable 7.0.1, Babel, and Node 6, it seems that merge skips properties where the key is a Symbol, while set (correctly) sets them. It works with normal objects. Example:

babel> const Immutable =  require('seamless-immutable');
babel> const s = Symbol("sym mine");
babel> Immutable({}).merge({[s]: "sym val"})[s]
undefined // WRONG: expected 'sym val'
babel> Immutable({}).set(s, "sym val")[s]
'sym val' // CORRECT

However it works when the key is not a Symbol but a normal object:

> var Immutable =  require('seamless-immutable');
> var s = {name: "key obj"};
> Immutable({}).merge({[s]: "sym val"})[s]
'sym val'