setPrototypeOf not supported in IE9 - IE10
See original GitHub issueThe config for Object.setPrototypeOf
refers to support for IEs 9-11 (https://github.com/Financial-Times/polyfill-service/blob/master/polyfills/Object/setPrototypeOf/config.json), but the source repo refers to IE 11+ (https://github.com/paulmillr/es6-shim/blame/master/README.md#L78) – and indeed am finding errors using IE10 that boil down to the fill behaving incorrectly and causing incorrect inheritance behaviour in babel-transpiled code. (FYI Babel works around not having the setPrototypeOf
method present.)
My workaround (for anyone else hitting the same issue) is to add excludes=Object.setPrototypeOf
to my polyfill URL (so I’m not getting a bad fill added), and add import "core-js/fn/object/set-prototype-of";
early in my code (so that I do have a fill for compatible browsers). This works okay so far.
I’m thinking that the fix here is to not fill setPrototypeOf
for IE < 11, but I would imagine lots of other fills are relying on it… happy to submit a PR once steered!
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (1 by maintainers)
Top GitHub Comments
Hey @JakeChampion, I have the same issue. Here’s a codepen where you can repro it in IE9/10: https://codepen.io/anon/pen/JpQQMq
Looks like
Object.getPrototypeOf(Bar))
doesn’t return what we expect and the parent constructor never gets called. Note that the code is preprocessed with babel to the following:It works when setPrototypeOf polyfill is excluded, because babel does the following:
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
@kentcdodds I exclude it, and then manually reimport directly from
core-js
to make sure IE11 and similar have it. I do wonder if the fix for this is just to set the expected browser range here to match that of the underlying polyfill.