rename replaceInstanceSuperReferences to replaceSuperReferences in classes transformer and add breaks on method definitions

This commit is contained in:
Sebastian McKenzie
2015-01-15 23:08:28 +11:00
parent 88eacecd72
commit 3cf8a6df01

View File

@@ -136,7 +136,7 @@ Class.prototype.buildBody = function () {
for (var i in classBody) {
var node = classBody[i];
if (t.isMethodDefinition(node)) {
this.replaceInstanceSuperReferences(node);
this.replaceSuperReferences(node);
if (node.key.name === "constructor") {
this.pushConstructor(node);
@@ -301,7 +301,7 @@ Class.prototype.looseSuperProperty = function (methodNode, id, parent) {
* @param {Node} methodNode MethodDefinition
*/
Class.prototype.replaceInstanceSuperReferences = function (methodNode) {
Class.prototype.replaceSuperReferences = function (methodNode) {
var method = methodNode.value;
var self = this;
@@ -324,6 +324,11 @@ Class.prototype.replaceInstanceSuperReferences = function (methodNode) {
return this.skip();
}
if (t.isProperty(node, { method: true }) || t.isMethodDefinition(node)) {
// break on object methods
return this.skip();
}
var getThisReference = function () {
if (topLevel) {
// top level so `this` is the instance