Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

babel-traverse module: explode function: ensure any prototype properties of cloned 'fns' object are retained #11820

Closed
wants to merge 1 commit into from
Closed

Conversation

jayaddison
Copy link
Contributor

@jayaddison jayaddison commented Jul 10, 2020

Q                       A
Patch: Bug Fix? No
Major: Breaking Change? No
Minor: New Feature? No
Tests Added + Pass? No
Any Dependency Changes? No
License MIT

This change is a fixup and continuation of changes applied in #11811 to remove usages of the lodash/clone function.

Ref: #11811 (comment)

@babel-bot
Copy link
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/25804/

@codesandbox-ci
Copy link

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 cf01c15:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

@nicolo-ribaudo
Copy link
Member

Do we need to do this? I feel like the original behavior was just an unwanted side effect.

@jayaddison
Copy link
Contributor Author

Hrm. On the one hand, mergePairs seems to operate only using enumerable keys when copying from a src object; I read that as a sign that the intent of the code is only to care about enumerable properties.

On the other hand, visitors is exported by the top-level babel-traverse module which could be an argument in favour of keeping things strictly the same behaviour-wise -- or it could be time for a wake-up call to anyone somehow relying on non-enumerable properties being exposed.

I'd probably be in favour of simplifying the set of properties (just in terms of simplicity and reducing undefined/unexpected behaviours outside the intent of the code) -- as long as that's not going to set half the JS ecosystem on fire.

cc @coreyfarrell just in case you missed any of this; this is a discussion around maintaining edge-case behaviour after replacing lodash/clone.

@coreyfarrell
Copy link
Contributor

In the strictest view dropping the prototype could be a breaking change, but other interpretations could view it is a bug fix. I don't have a strong opinion about this patch being needed for v7, v8, both or neither. This edge case will not cause trouble for any babel plugin I've ever worked on. My primary concern was that the edge case be noticed so it can be decided what if anything to do. @jayaddison thanks for posting this PR!

@jayaddison
Copy link
Contributor Author

Thanks @coreyfarrell!

If we're ok without needing this (at least until we discover any use cases where it does/could cause problems), then I think from a simplicity point of view it'd be preferable to close this. I think/hope we'd be able to reference and re-apply this later quickly if needed (hopefully there are enough relevant search terms in the GitHub discussion and topic.. I might add one or two more).

@jayaddison jayaddison changed the title Fixup: ensure any prototype properties of cloned 'fns' object are retained babel-traverse module: explode function: ensure any prototype properties of cloned 'fns' object are retained Jul 30, 2020
@JLHwung JLHwung closed this Jul 30, 2020
@jayaddison jayaddison deleted the dependencies/lodash-clone-fixup branch July 30, 2020 23:19
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 30, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants