Merge pull request #3550 from loganfsmyth/fix-jsx-self-mistakes

Fix some mistakes in the jsx-self transform.
This commit is contained in:
Logan Smyth 2016-06-26 13:56:27 -07:00 committed by GitHub
commit 15f267b7af

View File

@ -1,7 +1,6 @@
/**
* This adds {fileName, lineNumber} annotations to React component definitions
* and to jsx tag literals.
/**
* This adds a __self={this} JSX attribute to all JSX elements, which React will use
* to generate some runtime warnings.
*
*
* == JSX Literals ==
@ -17,10 +16,11 @@ const TRACE_ID = "__self";
export default function ({ types: t }) {
let visitor = {
JSXOpeningElement(node) {
JSXOpeningElement({ node }) {
const id = t.jSXIdentifier(TRACE_ID);
const trace = t.identifier("this");
node.container.openingElement.attributes.push(t.jSXAttribute(id, t.jSXExpressionContainer(trace)));
const trace = t.thisExpression();
node.attributes.push(t.jSXAttribute(id, t.jSXExpressionContainer(trace)));
}
};