polyfill-library: Invalid descriptor for property '0'
In IE 11, I’m getting the error:
Invalid descriptor for property ‘0’
Walking up the call stack, it’s stemming from some code that is constructing a DOMTokenList with a body element and 'className':
e=new DOMTokenList(body, 'className');
…which eventually hits this code which throws the error:
_(y,n,r)
_is some function nameddefinePropertyyis some objectnis0ris set toundefined
I’m using this polyfill URL (linebreaks added for readability):
https://cdn.polyfill.io/v2/polyfill.min.js
?unknown=polyfill
&features=
default%2C
fetch%2C
Array.prototype.%40%40iterator%2C
Array.prototype.find%2C
Array.prototype.findIndex%2C
Function.name%2C
Number.isFinite%2C
Promise%2C
String.prototype.repeat%2C
Array.prototype.includes%2C
Intl.~locale.en-US%2C
Promise.prototype.finally
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 10
- Comments: 21 (5 by maintainers)
With this code is possible to simulate on IE11 or also Chrome 37 (Before Symbol support) since it is easier to debug on Chrome:
At some point the key
Symbol.toStringTagin the Object.prototype is being deleted. I am having this issue using Webpack + ReactUniversalComponent in dev mode.Here’s the unminified stacktrace:
That
setDescriptorfunction is from theSymbolpolyfill:If I try the same call in Firefox (
Object.defineProperty(Object.prototype, '0', undefined)) I get the errorTypeError: descriptor must be an object, got undefined, so this probably isn’t exclusively an IE11 bug, it probably occurs in IE11 because IE is the only major browser that gets the DOMTokenList polyfill.Using in combination with Next.js, also bumping on this issue. Any real workaround?
@JakeChampion Also seeing this. I’m on polyfill-library@3.33.0. I am unable to create a repro on jsbin because repro involves a giant IE11 polyfill file. However, I am generating that file like this:
Include that file in a barebones HTML file:
Open the console in IE11, and evaluate
Object.assign(without even invoking it) yielding the error:Stack:
Frame:
I was able to replicate this when using both
core-js(through babelpreset-env) andpolyfill.io.Excluding
web.dom-collections.iteratorandweb.dom-collections.for-eachin your babel config might help. exampleBut
core-jsandpolyfill.iohave other conflicts so you will likely get other errors even if you exclude those.Does the error happen simply by loading the polyfills on a blank page or is there surrounding code? If there is extra code, can you share the url where this happens?
In scrutinizing further, it seems clear that it’s in the defining of indexer properties where this problem is occurring:
https://github.com/Financial-Times/polyfill-service/blob/1f45e5b95625180117d5b2f1979d8e217bc791a4/packages/polyfill-library/polyfills/_DOMTokenList/polyfill.js#L35-L41