dont coerce jsx expression containers - fixes #1126

This commit is contained in:
Sebastian McKenzie
2015-04-01 14:07:26 +11:00
parent 5f159853d5
commit 424a59a856
4 changed files with 21 additions and 4 deletions

View File

@@ -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;

View File

@@ -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);
}