Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symbol.for error on IE11 #365

Closed
2 tasks
faberyx opened this issue May 14, 2019 · 7 comments · Fixed by danactive/history#415
Closed
2 tasks

Symbol.for error on IE11 #365

faberyx opened this issue May 14, 2019 · 7 comments · Fixed by danactive/history#415

Comments

@faberyx
Copy link
Contributor

faberyx commented May 14, 2019

🐛 Bug Report

I get this error on IE11:
Object doesn't support property or method 'for'

on

var DRAFTABLE = typeof Symbol !== "undefined" ? Symbol.for("immer-draftable") : "__$immer_draftable";
var DRAFT_STATE = typeof Symbol !== "undefined" ? Symbol.for("immer-state") : "__$immer_state";

on IE11 Symbol is not undefined actually but for it is, so I guess there should be also a check for Symbol.for existence like typeof Symbol === 'function' && Symbol.for

this appeared on the latest version of immer, previous version were (I was on 2.0.0) not affected

To Reproduce

Using the latest version of immer I get this error on IE11: Object doesn't support property or method 'for'

Environment

  • Immer version: 3.1.1
  • Occurs with setUseProxies(true)
  • Occurs with setUseProxies(false) (ES5 only)
@faberyx faberyx added the bug label May 14, 2019
@mweststrate
Copy link
Collaborator

mweststrate commented May 14, 2019 via email

@faberyx
Copy link
Contributor Author

faberyx commented May 14, 2019

I'm not using a polyfill actually (and I would prefer to avoid it if possible :) ).
In version 2.0.0
var DRAFT_STATE = typeof Symbol !== "undefined" ? Symbol("immer-state") : "__$immer_state";
was working fine in IE11 without requiring to add Symbol polyfill, while on version 2.1.3 was changed to
var DRAFT_STATE = typeof Symbol !== "undefined" ? Symbol.for("immer-state") : "__$immer_state";
which brakes IE11 because Symbol is not undefined but Symbol.for actually is. Adding a && Symbol.for would fix the issue on IE11 without requiring to add a polyfill for it.

thank you!

@mweststrate
Copy link
Collaborator

mweststrate commented May 14, 2019 via email

@graue
Copy link

graue commented May 14, 2019

Fascinating. I've seen other problems with Immer and IE11 (see #362), but not this one. In fact when I start an IE11 session in Browserstack and go into the console I can use Symbol.for just fine with no issues at all.

@mweststrate
Copy link
Collaborator

mweststrate commented May 14, 2019 via email

@faberyx
Copy link
Contributor Author

faberyx commented May 14, 2019

😄 microsoft browsers have always been erratic.. 🙈 unfortunately we still have traffic on IE and with great pain we need to support it. I have v. 11.590.17134.0 installed
according to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/for is not supported on IE

@aleclarson
Copy link
Member

🎉 This issue has been resolved in version 3.1.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants