start adding support for this mapping for supers
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user