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

Freezing object after adding to WeakMap in IE11 #384

Closed
smares opened this issue Mar 2, 2018 · 2 comments
Closed

Freezing object after adding to WeakMap in IE11 #384

smares opened this issue Mar 2, 2018 · 2 comments

Comments

@smares
Copy link

smares commented Mar 2, 2018

I just stumbled upon a problem that affects only IE 11. It does not happen with IE 9, IE 10, Edge, Firefox or Chrome:

var wm = new WeakMap()
var key = {}

wm.set(key, 'foo')
console.log(wm.get(key)) // yield: 'foo'
Object.freeze(key)
console.log(wm.get(key)) // yield: 'undefined' for ie11 using polyfill | 'foo' for ie11 without polyfill

The latter case should be correct, wm.get(key) after calling Object.freeze(key) should return foo as it does in IE 9 with polyfill, IE 10 with polyfill, IE 11 without polyfill, Edge without polyfill, Chrome without polyfill and Firefox without polyfill.

@smares smares changed the title Object.freeze polyfill mutates object so that it cannot be used as WeakMap key Object.freeze polyfill mutates object in IE 11 so that it cannot be used as WeakMap key Mar 2, 2018
@zloirock
Copy link
Owner

zloirock commented Mar 2, 2018

You have confused the cause and effect. Without a polyfill, IE11 WeakMap can't work with frozen keys completely. core-js adds a fallback and it includes mutation objects in Object.freeze. But this fix does not cover the case from your example, so yes, it can be marked as a bug.

@zloirock zloirock changed the title Object.freeze polyfill mutates object in IE 11 so that it cannot be used as WeakMap key Freezing object after adding to WeakMap in IE11 Mar 2, 2018
@zloirock
Copy link
Owner

Fixed in v3 branch.

@zloirock zloirock mentioned this issue Mar 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants