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 194 forks source link

setIn creates extra array in certain situation, w strange behavior #151

Closed marbemac closed 7 years ago

marbemac commented 7 years ago

setIn seems to create an array, if setting an object property on an array that already exists. Although it seems like it's an array, that's an object? Or something of the sort, I'm not sure, I've never seen this before... it's odd. Screenshots to show what I mean

var x = Immutable({foo: []})
x.setIn(['foo', 0, 'bar'], 'val')

// results in
{
    foo: [
        [ ... array object thing?
            bar: val
        ]
    ]
}
screen shot 2016-09-20 at 7 03 17 pm

When stringified, it's as if setIn never happened...

screen shot 2016-09-20 at 7 08 27 pm

Confirmed in Chrome 52.0.2743.116, OS X, latest seamless-immutable.