move children prop pushing to after props to ensure correct order - fixes #2395

This commit is contained in:
Sebastian McKenzie
2015-11-08 06:24:10 -08:00
parent 8f00700b9f
commit 2a1a038031
3 changed files with 20 additions and 8 deletions

View File

@@ -42,14 +42,6 @@ export default function ({ types: t }) {
objProps.push(t.objectProperty(key, value));
}
if (node.children.length) {
let children = t.react.buildChildren(node);
if (children.length) {
children = children.length === 1 ? children[0] : t.arrayExpression(children);
pushProp(props.properties, t.identifier("children"), children);
}
}
// props
for (let attr of (open.attributes: Array<Object>)) {
if (isJSXAttributeOfName(attr, "key")) {
@@ -61,6 +53,14 @@ export default function ({ types: t }) {
}
}
if (node.children.length) {
let children = t.react.buildChildren(node);
if (children.length) {
children = children.length === 1 ? children[0] : t.arrayExpression(children);
pushProp(props.properties, t.identifier("children"), children);
}
}
if (isComponent) {
props = t.callExpression(file.addHelper("defaultProps"), [t.memberExpression(type, t.identifier("defaultProps")), props]);
}