dont coerce jsx expression containers - fixes #1126
This commit is contained in:
@@ -144,10 +144,14 @@ export default function (exports, opts) {
|
||||
};
|
||||
|
||||
exports.JSXElement = {
|
||||
enter(node) {
|
||||
node.children = react.buildChildren(node);
|
||||
},
|
||||
|
||||
exit(node) {
|
||||
var callExpr = node.openingElement;
|
||||
|
||||
callExpr.arguments = callExpr.arguments.concat(react.buildChildren(node));
|
||||
callExpr.arguments = callExpr.arguments.concat(node.children);
|
||||
|
||||
if (callExpr.arguments.length >= 3) {
|
||||
callExpr._prettyCall = true;
|
||||
|
||||
6
src/babel/transformation/helpers/react.js
vendored
6
src/babel/transformation/helpers/react.js
vendored
@@ -81,15 +81,15 @@ export function buildChildren(node) {
|
||||
|
||||
for (var i = 0; i < node.children.length; i++) {
|
||||
var child = node.children[i];
|
||||
if (t.isJSXExpressionContainer(child)) child = child.expression;
|
||||
|
||||
if (t.isLiteral(child) && typeof child.value === "string") {
|
||||
cleanJSXElementLiteralChild(child, elems);
|
||||
continue;
|
||||
} else if (t.isJSXEmptyExpression(child)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (t.isJSXExpressionContainer(child)) child = child.expression;
|
||||
if (t.isJSXEmptyExpression(child)) continue;
|
||||
|
||||
elems.push(child);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user