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

Importing es/reflect/set pollutes Object's prototype with {a: 1} in IE11 #847

Closed
burkov opened this issue Jul 21, 2020 · 4 comments
Closed

Comments

@burkov
Copy link

burkov commented Jul 21, 2020

Following piece of code leaves field a set to 1 in Object's prototype in IE11. This breaks jquery.keyfilter for instance and also looks strange in dev console.

// MS Edge 17-18 Reflect.set allows setting the property to object
// with non-writable property on the prototype
var MS_EDGE_BUG = fails(function () {
  var object = definePropertyModule.f({}, 'a', { configurable: true });
  // eslint-disable-next-line no-undef
  return Reflect.set(getPrototypeOf(object), 'a', 1, object) !== false;
});

$({ target: 'Reflect', stat: true, forced: MS_EDGE_BUG }, {
  set: set
});

photo_2020-07-21_19-03-45

Think it should be cleaned up right after the test with something like delete Object.prototype.a

@daniel-civicore
Copy link

daniel-civicore commented Jul 22, 2020

This is also happening with arrays. Not sure if it is happening due to the same code or not but same thing is being seen.

new Array().a
// 1

This causes major issues in the case of arrays because if you try to loop over the array it returns "a" as a key:
for (var key in [1,2,3]) {
console.log(key);
}
// 0
// 1
// 2
// a

This ends up breaking most things, including jQuery. This is also an issue in Safari 9.

@daniel-civicore
Copy link

So I found more details on my specific issue. We include google charts on our page: https://www.gstatic.com/charts/loader.js

If you look at this it appears to do some polyfills for some array functionality. If these polyfills loads before the core-js polyfills then it throws this error. However, if we load core-js first, then it doesn't have the issue. So I am guessing something this is doing is confusing core-js.

This wasn't always an issue so I think the google charts must have been updated recently.

@zloirock
Copy link
Owner

It's a bug in a 3rd party polyfill that does not support receiver argument of Reflect.set. It's not a core-js issue.

@zloirock
Copy link
Owner

I'll add a workaround since it's very simple.

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

No branches or pull requests

3 participants