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

Use the correct this in __self for JSX elements in arrows #11288

Merged
merged 6 commits into from Mar 19, 2020

Conversation

nicolo-ribaudo
Copy link
Member

Q                       A
Fixed Issues? Reported on Twitter
Patch: Bug Fix? Yes
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

The problem was that we were injecting __self after transpiling arrow functions, and thus it didn't receive the outer this but the one of the new function expression.

This PR fixes the problem by injecting __self and __source in Program:enter.

Probably windows tests will fail because I tried to manually edit them, I'll fix them after CI tells me the necessary updated.

@nicolo-ribaudo nicolo-ribaudo added PR: Bug Fix 🐛 A type of pull request used for our changelog categories area: jsx labels Mar 19, 2020
@@ -1,31 +0,0 @@
var actual = transform(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I merged this test to the one that runs on linux. Also, I made it input/output rather than calling transform in exec.js.

@lunaruan
Copy link
Contributor

Should we also fix the transform-react-jsx-self plugin so that everyone using that also gets the fix?

Copy link
Member

@hzoo hzoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome, so we are deprecating the standalone plugins now? (although also true it has been that way since the beginning)

edit: yeah was going to ask the same as @lunaruan

@nicolo-ribaudo
Copy link
Member Author

I can prepare another PR for the standalone plugins, but given that they have been proven for years and that they shouldn't be used anymore I don't think that it's worth it 🤷‍♀️

@nicolo-ribaudo nicolo-ribaudo merged commit 11292a3 into babel:master Mar 19, 2020
@lunaruan
Copy link
Contributor

lunaruan commented Mar 19, 2020

__self is used primarily for a string ref deprecation warning that we have recently enabled. We are worried that people will take some time to upgrade to Babel 8.0 and use the new transform. We would like them to be able to get this warning ASAP so that they can work on removing string refs before they are deprecated, so we would prefer that it is also added to the self transform. Is this okay with you?

Thanks again for doing this!

@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 Jun 19, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: jsx outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants