ljharb / object.assign

ES6 spec-compliant Object.assign shim. From https://github.com/es-shims/es6-shim
https://tc39.es/ecma262/#sec-object.assign
MIT License
107 stars 22 forks source link

Remove dependency on function-bind #42

Closed juandopazo closed 7 years ago

juandopazo commented 7 years ago

Hi!

function-bind is a very good implementation that follows the spec very closely. The problem is that in order to follow the spec it must use eval to ensure the bound function has a correct length property. This is an issue in environments that use Content Security Policy to block eval.

However, object.assign doesn't really need that behavior, or anything related to new for that matter, so a minimal bind implementation is enough for it. This PR removes the dependency on function-bind and replaces it with a very naive bind function.

Thoughts?

ljharb commented 7 years ago

The easiest solution here is for you to use browserify or webpack to replace function-bind with a module that exports Function.prototype.bind, since you are in a position to know that's supported for your environments.

What might be a reasonable middle ground, however, is adding a new entry point to function-bind, such that one could do require('function-bind/minimal') or something, and then update this module to use that - that way CSP wouldn't complain.