add isFalsyExpression check to superName and make classes a closure if they're inheriting
This commit is contained in:
@@ -102,6 +102,7 @@ Class.prototype.run = function () {
|
||||
//
|
||||
|
||||
if (superName) {
|
||||
this.closure = true;
|
||||
body.push(t.expressionStatement(t.callExpression(file.addDeclaration("inherits"), [className, superName])));
|
||||
}
|
||||
|
||||
@@ -153,7 +154,7 @@ Class.prototype.buildBody = function () {
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.hasConstructor && superName) {
|
||||
if (!this.hasConstructor && superName && !t.isFalsyExpression(superName)) {
|
||||
constructor.body.body.push(util.template("class-super-constructor-call", {
|
||||
SUPER_NAME: superName
|
||||
}, true));
|
||||
|
||||
@@ -74,6 +74,17 @@ addAssert("Expression", t.isExpression);
|
||||
|
||||
//
|
||||
|
||||
t.isFalsyExpression = function (node) {
|
||||
if (t.isLiteral(node)) {
|
||||
return !node.value;
|
||||
} else if (t.isIdentifier(node)) {
|
||||
return node.name === "undefined";
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
//
|
||||
|
||||
t.toSequenceExpression = function (nodes, scope) {
|
||||
var exprs = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user