From 856b1f29230acc829d627aa8779f345c71a3ddaa Mon Sep 17 00:00:00 2001 From: Logan Smyth Date: Sun, 26 Jun 2016 13:41:44 -0700 Subject: [PATCH] Fix some mistakes in the jsx-self transform. --- .../src/index.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/babel-plugin-transform-react-jsx-self/src/index.js b/packages/babel-plugin-transform-react-jsx-self/src/index.js index 85113bca0c..2fd02a77ed 100644 --- a/packages/babel-plugin-transform-react-jsx-self/src/index.js +++ b/packages/babel-plugin-transform-react-jsx-self/src/index.js @@ -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))); } };