Bug: minified version of Function.prototype.name feature detect is incorrect
See original GitHub issueThe feature detect for Function.prototype.name is this:
'name' in Function.prototype && (function x() {}).name === 'x'
but when minified it is turned into this:
"name"in Function.prototype&&"x"===function(){}.name
which is incorrect because "x"===function(){}.name
will always evaluate to false.
Pollyfills used: polyfill.js?features=default,es6 Pollyfill with issue: Object.defineProperty
stack trace:
defineProperty | @ | polyfill.js?features=default,es6:414 -- | -- | -- defineProp | @ | polyfill.js?features=default,es6:414 (anonymous function) | @ | app.js:1
I have a library somwhere inside one of my 1 million NPM packages that is trying to defined the property items ontop of an empty array (basically Object.defineProperty([], “items”, config)) however the issue is ONLY happening on iOS 8, every other browser is fine with it. For this reason I am unable to figure out which of the million packages is doing this as I browserstack for whatever reasons is having a bad day when it comes to sourcemaps.
This is making it so that I have 0 idea what is causing this error so I cannot just remove the package which is doing this and move on. All that being said, is it correct behaviour for the pollyfill service to fix this? I can’t even tell if pollyfill.js is pollyfilling my browser 😦
I know this is a useless issue submission with very little info but I’m really at my witts end and this is basically just a cry for help. I am just hoping sombody has seen this before and knows a way to fix it. I’m hoping that it’s not that I’m stuck and that theres somthing stupid I need to fix.
Sorry.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:24 (12 by maintainers)
Top GitHub Comments
@rmja both your commands return 3.34.0 for me, I’m not sure what else to check here, I know polyfill-service uses 3.34.0 and I have emptied the cache in our CDN to ensure everyone get’s the latest version so long as they do not have a local cached copy.
I can confirm the bug this issue is about does exist in 3.34.0 via this url https://polyfill.io/v3/polyfill.js?flags=gated,always&features=Function.prototype.name&excludes=Object.defineProperty
@rmja, the symptom you are seeing is that the polyfill will not work in browsers which already support the feature. The reason that happens for your original request is because the user-agent is detected as one we do not support and so we serve it all the requested polyfills and put them behind feature detects however, the feature detects are served in a minified format and the minifier was not preserving the function names, which made the feature detect for function.prototype.name support always return false , even for browsers which do support function.prototype.name.