diff --git a/lib/6to5/transformation/transformers/es6-classes.js b/lib/6to5/transformation/transformers/es6-classes.js index 18c2657ca3..e1ccf2cf2f 100644 --- a/lib/6to5/transformation/transformers/es6-classes.js +++ b/lib/6to5/transformation/transformers/es6-classes.js @@ -208,7 +208,7 @@ Class.prototype.pushMethod = function (node) { * @returns {Node} */ -Class.prototype.superProperty = function (property, isStatic, isComputed) { +Class.prototype.superProperty = function (property, isStatic, isComputed, thisExpression) { return t.callExpression( this.file.addHelper("get"), [ @@ -218,7 +218,8 @@ Class.prototype.superProperty = function (property, isStatic, isComputed) { isStatic ? this.className : t.memberExpression(this.className, t.identifier("prototype")) ] ), - isComputed ? property : t.literal(property.name), t.thisExpression() + isComputed ? property : t.literal(property.name), + thisExpression ] ); }; @@ -231,7 +232,7 @@ Class.prototype.superProperty = function (property, isStatic, isComputed) { Class.prototype.replaceInstanceSuperReferences = function (methodNode) { var method = methodNode.value; - var self = this; + var self = this; traverse(method, { enter: function (node, parent) { @@ -245,7 +246,7 @@ Class.prototype.replaceInstanceSuperReferences = function (methodNode) { } } else if (t.isCallExpression(node)) { var callee = node.callee; - if (t.isIdentifier(callee) && callee.name === "super") { + if (t.isIdentifier(callee, { name: "super" })) { // super(); -> _get(Object.getPrototypeOf(ClassName), "MethodName", this).call(this); property = methodNode.key; computed = methodNode.computed; @@ -268,11 +269,12 @@ Class.prototype.replaceInstanceSuperReferences = function (methodNode) { } if (property) { - var superProperty = self.superProperty(property, methodNode.static, computed); + var thisExpression = t.thisExpression(); + var superProperty = self.superProperty(property, methodNode.static, computed, thisExpression); if (args) { return t.callExpression( t.memberExpression(superProperty, t.identifier("call"), false), - [t.thisExpression()].concat(args) + [thisExpression].concat(args) ); } else { return superProperty;