diff --git a/lib/6to5/transformation/transformers/other/react.js b/lib/6to5/transformation/transformers/other/react.js index 08ccc30356..43803868af 100644 --- a/lib/6to5/transformation/transformers/other/react.js +++ b/lib/6to5/transformation/transformers/other/react.js @@ -8,8 +8,10 @@ var esutils = require("esutils"); var t = require("../../../types"); -exports.JSXIdentifier = function (node) { - if (esutils.keyword.isIdentifierName(node.name)) { +exports.JSXIdentifier = function (node, parent) { + if (node.name === "this" && t.isReferenced(node, parent)) { + return t.thisExpression(); + } else if (esutils.keyword.isIdentifierName(node.name)) { node.type = "Identifier"; } else { return t.literal(node.name); diff --git a/test/fixtures/transformation/react/arrow-functions/actual.js b/test/fixtures/transformation/react/arrow-functions/actual.js new file mode 100644 index 0000000000..fc0906b174 --- /dev/null +++ b/test/fixtures/transformation/react/arrow-functions/actual.js @@ -0,0 +1,3 @@ +var foo = function () { + return () => ; +}; diff --git a/test/fixtures/transformation/react/arrow-functions/expected.js b/test/fixtures/transformation/react/arrow-functions/expected.js new file mode 100644 index 0000000000..ba37738e61 --- /dev/null +++ b/test/fixtures/transformation/react/arrow-functions/expected.js @@ -0,0 +1,6 @@ +var foo = function () { + var _this = this; + return function () { + return React.createElement(_this, null); + }; +};