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

Wrap frozen keys fix in try-catch not to break other WeakMap polyfills implementations #252

Closed
wants to merge 1 commit into from

Conversation

eugef
Copy link

@eugef eugef commented Oct 18, 2016

Other WeakMap polyfills throw an error if frozen object is being passed as a key.
So we simply ignore the error that this check produces.

This could happen if another polyfill was already executed on the page.

…s implementations

Other WeakMap polyfills throw an error if frozen object is being passed as a key.
So we simply ignore the error that this check produces.

This could happen if another polyfill was already executed on the page.
@eugef
Copy link
Author

eugef commented Dec 2, 2016

@zloirock could you review the PR?

@Jessidhia
Copy link

If there is a WeakMap polyfill that will crash when receiving a frozen object, then the bad polyfill should get overridden by core-js, instead of crashing (or being skipped, like this PR does).

Something like function isBad () { try { return new $WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7 } catch (e) { return true } } if (isBad()) { ... } might be more appropriate.

@eugef
Copy link
Author

eugef commented Dec 5, 2016

@Kovensky you are right, but unfortunately it is not always possible to do that.
And my PR just allows core-js to be more friendly to other code that can be already used on the page.

@zloirock
Copy link
Owner

zloirock commented Dec 5, 2016

I agree with @Kovensky. I'll add something for that.

@zloirock zloirock closed this in 9e03f88 Apr 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants