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

Fix for AMD & Symbol polyfill race condition #255

Open ndreckshage opened 6 years ago

ndreckshage commented 6 years ago

Issue Summary

There is a race condition when using AMD for older browsers that use a Symbol polyfill. https://github.com/rtfeldman/seamless-immutable/blob/7.1.3/src/seamless-immutable.js#L7 this line detects whether a Symbol polyfill is used. However, immutableInit is called outside of define for AMD (https://github.com/rtfeldman/seamless-immutable/blob/7.1.3/src/seamless-immutable.js#L742).

If a polyfill is in a separate bundle than Seamless, there is a race condition, and if Seamless loads before the polyfill, browsers that use the polyfill crash, because they don't break early on React elements.

Fix

crudh commented 5 years ago

@ndreckshage looks reasonable. Can you rebase it on current master, or submit a new PR with only your changes? The CI build has been fixed and additional commits were added to it.

And you can either rebuild the conflicting files or leave them out, I will do a build after merging anyway.