fix automatic closure on private declarations - fixes #335

This commit is contained in:
Sebastian McKenzie
2014-12-28 01:01:13 +11:00
parent 601bbb86cd
commit 322aa246b8
2 changed files with 20 additions and 12 deletions

View File

@@ -8,16 +8,24 @@ exports.ClassDeclaration = function (node, parent, file, scope) {
closure = false;
}
var newNode = new Class(node, file, scope, closure).run();
if (closure) {
// declaration in an expression context...
// export default class Foo {}
scope.push({
kind: "var",
key: node.id.key,
id: node.id
});
return t.assignmentExpression("=", node.id, newNode);
var factory = new Class(node, file, scope, closure);
var newNode = factory.run();
if (factory.closure) {
if (closure) {
// declaration in an expression context...
// export default class Foo {}
scope.push({
kind: "var",
key: node.id.key,
id: node.id
});
return t.assignmentExpression("=", node.id, newNode);
} else {
// likely has a PrivateDeclaration etc
return t.variableDeclaration("let", [
t.variableDeclarator(node.id, newNode)
]);
}
} else {
return newNode;
}