perform function name inference on functions in properties before they're properly visited - fixes #1860

This commit is contained in:
Sebastian McKenzie
2015-06-29 00:20:47 +01:00
parent 81edc4c6ab
commit 0044100e3d
5 changed files with 46 additions and 6 deletions

View File

@@ -4,8 +4,24 @@ export var metadata = {
group: "builtin-basic"
};
// visit Property functions first - https://github.com/babel/babel/issues/1860
export var visitor = {
"ArrowFunctionExpression|FunctionExpression": {
exit: bare
exit() {
if (!this.parentPath.isProperty()) {
return bare.apply(this, arguments);
}
}
},
ObjectExpression() {
var props = this.get("properties");
for (var prop of (props: Array)) {
var value = prop.get("value");
if (value.isFunction()) {
var newNode = bare(value.node, prop.node, value.scope);
if (newNode) value.replaceWith(newNode);
}
}
}
};