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

Add a test for bad Map polyfill, and work around Rollup bug #11745

Merged
merged 3 commits into from
Dec 2, 2017

Conversation

gaearon
Copy link
Collaborator

@gaearon gaearon commented Dec 1, 2017

This adds test coverage for these lines:

var hasBadMapPolyfill = false;
try {
var nonExtensibleObject = Object.preventExtensions({});
/* eslint-disable no-new */
new Map([[nonExtensibleObject, null]]);
new Set([nonExtensibleObject]);
/* eslint-enable no-new */
} catch (e) {
// TODO: Consider warning about bad polyfills
hasBadMapPolyfill = true;
}

I only did this for Map because it's a bit hacky, and I figured this would be enough to find regressions.

It fails the bundle tests because apparently Rollup strips the new calls out (which is how we discovered the problem with this check). So I added a workaround for that, and a TODO to report this to Rollup.

@gaearon gaearon changed the title Add a test for bad Map polyfill Add a test for bad Map polyfill, and work around Rollup bug Dec 1, 2017
@gaearon
Copy link
Collaborator Author

gaearon commented Dec 1, 2017

cc @lukastaegert, wondering if it's a known issue?

Copy link
Collaborator

@acdlite acdlite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool test!

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

Successfully merging this pull request may close these issues.

3 participants