Closed ColCh closed 5 years ago
This code breaks Function.prototype.name in 100% of cases
Function.prototype.name
var funcNameBeforeProtoCall = (function bar() {}).name var funcNameBeforeProtoCallEquals = funcNameBeforeProtoCall === 'bar'; debugger; Function.prototype.name; var funcNameAfterProtoCall = (function foo() {}).name var funcNameAfterProtoCallEquals = funcNameAfterProtoCall === 'foo'; debugger
launchable code: https://codepen.io/ColCh/pen/Oqpqqp
Try it in IE 11 and this would be resulted in this:
WHY ?!
Because this code is executed against this variable of Function.prototype
this
Function.prototype
https://github.com/paulmillr/es6-shim/blob/271142ca5c58b7bfec6970b1c070515da0d8ef98/es6-sham.js#L158-L159
and this code assigns getter with for Function.prototype name property with null value.
name
null
https://github.com/paulmillr/es6-shim/blob/271142ca5c58b7bfec6970b1c070515da0d8ef98/es6-sham.js#L160-L165
Solution: skip defineProperty for null names
defineProperty
ah, that's a really good catch - I don't think we ever expected anyone would refer to the name getter directly. Fix incoming.
Omg that was fast! Thank you!
This code breaks
Function.prototype.name
in 100% of caseslaunchable code: https://codepen.io/ColCh/pen/Oqpqqp
Try it in IE 11 and this would be resulted in this:
WHY ?!
Because this code is executed against
this
variable ofFunction.prototype
https://github.com/paulmillr/es6-shim/blob/271142ca5c58b7bfec6970b1c070515da0d8ef98/es6-sham.js#L158-L159
and this code assigns getter with for
Function.prototype
name
property withnull
value.https://github.com/paulmillr/es6-shim/blob/271142ca5c58b7bfec6970b1c070515da0d8ef98/es6-sham.js#L160-L165
Solution: skip
defineProperty
fornull
names