add isFalsyExpression check to superName and make classes a closure if they're inheriting
This commit is contained in:
parent
46632e1a97
commit
aee1ca45b0
@ -102,6 +102,7 @@ Class.prototype.run = function () {
|
|||||||
//
|
//
|
||||||
|
|
||||||
if (superName) {
|
if (superName) {
|
||||||
|
this.closure = true;
|
||||||
body.push(t.expressionStatement(t.callExpression(file.addDeclaration("inherits"), [className, superName])));
|
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", {
|
constructor.body.body.push(util.template("class-super-constructor-call", {
|
||||||
SUPER_NAME: superName
|
SUPER_NAME: superName
|
||||||
}, true));
|
}, 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) {
|
t.toSequenceExpression = function (nodes, scope) {
|
||||||
var exprs = [];
|
var exprs = [];
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user