Replace lodash 'clone' usage with ES6 Spread initializer#11811
Replace lodash 'clone' usage with ES6 Spread initializer#11811existentialism merged 2 commits intobabel:mainfrom jayaddison:dependencies/reduce-lodash-usage-clone
Conversation
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/25669/ |
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 6da65ba:
|
| mergePair(existing, fns); | ||
| } else { | ||
| visitor[alias] = clone(fns); | ||
| visitor[alias] = { ...fns }; |
There was a problem hiding this comment.
@jayaddison Sorry I missed this while it was open but I think this could introduce an edge case behavior change if fns has any non-enumerable values in the prototype chain. A better replacement might be:
visitor[alias] = Object.create(Object.getPrototypeOf(fns));
Object.assign(visitor[alias], fns);Here the cloned object is created with the prototype of fns, then Object.assign copies only the own iterable properties from fns.
There was a problem hiding this comment.
No problem at all, thanks for catching this. Fixup opened in #11820.
Continues removal of lodash function dependencies identified per #11789.