Fix incorrect property ordering with obj rest spread on nested (#5685)

This commit is contained in:
Brian Ng
2017-05-02 13:04:37 -05:00
committed by Henry Zhu
parent c307bbb3a9
commit 79c1eed8c1
5 changed files with 60 additions and 1 deletions

View File

@@ -117,15 +117,22 @@ export default function ({ types: t }) {
}
let ref = this.originalPath.node.init;
const refPropertyPath = [];
path.findParent((path) => {
if (path.isObjectProperty()) {
ref = t.memberExpression(ref, t.identifier(path.node.key.name));
refPropertyPath.unshift(path.node.key.name);
} else if (path.isVariableDeclarator()) {
return true;
}
});
if (refPropertyPath.length) {
refPropertyPath.forEach((prop) => {
ref = t.memberExpression(ref, t.identifier(prop));
});
}
const [ argument, callExpression ] = createObjectSpread(
file,
path.parentPath.node.properties,