ljharb / es-abstract

ECMAScript spec abstract operations.
MIT License
115 stars 30 forks source link

SES-shim Compat - Assigning to 'apply' to a fn is not permitted #112

Closed kumavis closed 3 years ago

kumavis commented 4 years ago

This assignment of apply on to module.exports throws an error under the ses-shim

https://github.com/ljharb/es-abstract/blob/67a1a94ee9c9b36d7505c0eac0e2b95a2811e5e4/helpers/callBind.js#L15

A non-breaking solution would be to append the export via Reflect.defineProperty instead of assignment

kumavis commented 4 years ago

as a breaking change, you could have the module export { call, apply } without overwriting callBind's apply fn

kumavis commented 4 years ago

maybe thats bug worthy on its own, without ses or ses-shim the following is true: the exported callBind fn is not called when attempted to be called via callBind.apply(...). it would instead incorrectly call the applyBind function.

ljharb commented 4 years ago

I think that it's reasonable to use https://github.com/ljharb/es-abstract/blob/master/helpers/DefineOwnProperty.js instead of assignment - I don't think a breaking change is warranted.