immutable-js/immutable-js

IE11 fromJS bug

rytisbac opened this issue · 8 comments

Version v4.0.0-rc.12
Function fromJS.
example:
console.log(fromJS({test: 'qqq'}))
In most of the browsers it returns Map object, but IE11 returns the same object.
Other case:
console.log(fromJS([{test: 'qqq'}]))
In most of the browsers it returns List and Map as first element, but IE11 returns List and initial object.

Version 3.8.2 works as expected

Any chance this will be addressed? It completely broke my application on internet explorer as I use fromJS a lot.
I can confirm that the issue was introduced with 4.0.0-rc10, up to 4.0.0-rc9 everything works fine

@thenano I had the same issue and was able to fix it installing the core-js es6.function.name polyfill.

EDIT: A little bit more of context:

After #1627, Immutable.fromJS function checks if the object to be transformed is a plain object using value.constructor.name === 'Object' which fails in IE since IE doesn't supports function.name. The polyfill allows the code to read functions name in IE.

List structure seems to be broken by using .concat() on IE11 on 4.0.0-rc.12.

But v3.8.2 works good.

Is it related to this issue?

How to reproduce

Please open below by IE11.

http://another.geniee.jp/test/ysato/immutable-bug/map.html

var MyRecord = Immutable.Record({a: 1});
var list = Immutable.List([]);
list = list.concat([new MyRecord({a: 2}), new MyRecord({a: 3})]);
console.log(JSON.stringify(list)); 
// from Chrome: [{"a":2},{"a":3}]
// from IE11: [[{"a":2},{"a":3}]]     <- it is incorrect

I had the same issue with fromJS

Me too. And when I execute the code :

Immutable.fromJS({a:1}).toJS()

In IE 11 ,it will throw exception Object don't support "toJS" prop or function,but in chrome it is work ok.

package.json

"immutable": "^4.0.0-rc.12",

But when I use the

"immutable": "^3.8.1"

It is work ok.

@cauethenorio You're the real mvp, the es6.function.name fixed it for me.

Thank you for your bug report. The immutable-js oss fork will soon be merged and a fix for this issue has been included in #1833. Once this PR is merged, this issue will be resolved in the main branch. We will then do our best to to release the 4.0.0 version.

Commit reference: f3a6d5c