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

Pass the correct this to JSX's __self with the old plugin #11290

Merged
merged 1 commit into from Mar 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/babel-plugin-transform-react-jsx-self/src/index.js
Expand Up @@ -30,6 +30,10 @@ export default declare(api => {

return {
name: "transform-react-jsx-self",
visitor,
visitor: {
Program(path) {
path.traverse(visitor);
},
},
};
});
@@ -0,0 +1,7 @@
<div />;
() => <div />;

function fn() {
<div />;
() => <div />;
}
@@ -0,0 +1,3 @@
{
"plugins": ["syntax-jsx", "transform-react-jsx-self", "transform-arrow-functions"]
}
@@ -0,0 +1,17 @@
var _this = this;

<div __self={this} />;

(function () {
return <div __self={_this} />;
});

function fn() {
var _this2 = this;

<div __self={this} />;

(function () {
return <div __self={_this2} />;
});
}

This file was deleted.

@@ -0,0 +1 @@
<Foo bar="baz" />;
@@ -0,0 +1,12 @@
var _jsxFileName = "C:\\Users\\travis\\build\\babel\\babel\\packages\\babel-preset-react\\test\\fixtures\\preset-options\\development-windows\\input.js";

/*#__PURE__*/
React.createElement(Foo, {
bar: "baz",
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 1,
columnNumber: 1
}
});

This file was deleted.

@@ -0,0 +1 @@
<Foo bar="baz" />;
@@ -0,0 +1,12 @@
var _jsxFileName = "<CWD>/packages/babel-preset-react/test/fixtures/preset-options/development/input.js";

/*#__PURE__*/
React.createElement(Foo, {
bar: "baz",
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 1,
columnNumber: 1
}
});