diff --git a/lib/6to5/transformation/transformers/es6-classes.js b/lib/6to5/transformation/transformers/es6-classes.js index 75bccb3073..3de58f0f0f 100644 --- a/lib/6to5/transformation/transformers/es6-classes.js +++ b/lib/6to5/transformation/transformers/es6-classes.js @@ -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)); diff --git a/lib/6to5/types/index.js b/lib/6to5/types/index.js index 4745caedad..2978115f63 100644 --- a/lib/6to5/types/index.js +++ b/lib/6to5/types/index.js @@ -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 = [];