clean up es6.objectSuper transformer - fixes #1502

This commit is contained in:
Sebastian McKenzie 2015-05-11 22:34:08 +01:00
parent 2b42773e01
commit 941474983d

View File

@ -2,30 +2,19 @@ import ReplaceSupers from "../../helpers/replace-supers";
import * as t from "../../../types";
function Property(path, node, scope, getObjectRef, file) {
if (!node.method) return;
var value = node.value;
var thisExpr = scope.generateUidIdentifier("this");
if (!node.method && node.kind === "init") return;
if (!t.isFunction(node.value)) return;
var replaceSupers = new ReplaceSupers({
topLevelThisReference: thisExpr,
getObjectRef: getObjectRef,
methodNode: node,
methodPath: path,
isStatic: true,
scope: scope,
file: file
getObjectRef: getObjectRef,
methodNode: node,
methodPath: path,
isStatic: true,
scope: scope,
file: file
});
replaceSupers.replace();
if (replaceSupers.hasSuper) {
value.body.body.unshift(
t.variableDeclaration("var", [
t.variableDeclarator(thisExpr, t.thisExpression())
])
);
}
}
export function ObjectExpression(node, parent, scope, file) {