properly transform XJSIdentifier nodes referencing this into a ThisExpression - facebook/react#2927
This commit is contained in:
parent
bbbc9c0c5e
commit
bf393c025f
@ -8,8 +8,10 @@
|
|||||||
var esutils = require("esutils");
|
var esutils = require("esutils");
|
||||||
var t = require("../../../types");
|
var t = require("../../../types");
|
||||||
|
|
||||||
exports.JSXIdentifier = function (node) {
|
exports.JSXIdentifier = function (node, parent) {
|
||||||
if (esutils.keyword.isIdentifierName(node.name)) {
|
if (node.name === "this" && t.isReferenced(node, parent)) {
|
||||||
|
return t.thisExpression();
|
||||||
|
} else if (esutils.keyword.isIdentifierName(node.name)) {
|
||||||
node.type = "Identifier";
|
node.type = "Identifier";
|
||||||
} else {
|
} else {
|
||||||
return t.literal(node.name);
|
return t.literal(node.name);
|
||||||
|
|||||||
3
test/fixtures/transformation/react/arrow-functions/actual.js
vendored
Normal file
3
test/fixtures/transformation/react/arrow-functions/actual.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
var foo = function () {
|
||||||
|
return () => <this />;
|
||||||
|
};
|
||||||
6
test/fixtures/transformation/react/arrow-functions/expected.js
vendored
Normal file
6
test/fixtures/transformation/react/arrow-functions/expected.js
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
var foo = function () {
|
||||||
|
var _this = this;
|
||||||
|
return function () {
|
||||||
|
return React.createElement(_this, null);
|
||||||
|
};
|
||||||
|
};
|
||||||
Loading…
x
Reference in New Issue
Block a user