Merge pull request #1916 from conradz/inline-single-child

Handle single child when using React inlining
This commit is contained in:
Sebastian McKenzie 2015-07-04 11:23:15 +02:00
commit e9793b1f16
3 changed files with 6 additions and 4 deletions

View File

@ -49,7 +49,9 @@ export var visitor = {
pushElemProp("ref", t.literal(null));
if (node.children.length) {
pushProp(props.properties, t.identifier("children"), t.arrayExpression(react.buildChildren(node)));
var children = react.buildChildren(node);
children = children.length === 1 ? children[0] : t.arrayExpression(children);
pushProp(props.properties, t.identifier("children"), children);
}
// props

View File

@ -16,11 +16,11 @@ function render() {
type: "foo",
ref: null,
props: {
children: [text]
children: text
},
key: null
};
return function () {
return _ref2;
};
}
}

View File

@ -4,7 +4,7 @@
type: "div",
ref: null,
props: {
children: [bar],
children: bar,
className: "foo"
},
key: null