remove apply-constructor helper from es6.spread transformer - fixes #1052

This commit is contained in:
Sebastian McKenzie 2015-03-23 16:51:14 +11:00
parent b234603e24
commit 01463faf36

View File

@ -101,14 +101,8 @@ export function NewExpression(node, parent, scope, file) {
var args = node.arguments;
if (!hasSpread(args)) return;
var nativeType = this.get("callee").isIdentifier() && includes(t.NATIVE_TYPE_NAMES, node.callee.name);
var nodes = build(args, scope);
if (nativeType) {
nodes.unshift(t.arrayExpression([t.literal(null)]));
}
var first = nodes.shift();
if (nodes.length) {
@ -117,15 +111,11 @@ export function NewExpression(node, parent, scope, file) {
args = first;
}
if (nativeType) {
return t.newExpression(
t.callExpression(
t.memberExpression(file.addHelper("bind"), t.identifier("apply")),
[node.callee, args]
),
[]
);
} else {
return t.callExpression(file.addHelper("apply-constructor"), [node.callee, args]);
}
return t.newExpression(
t.callExpression(
t.memberExpression(file.addHelper("bind"), t.identifier("apply")),
[node.callee, args]
),
[]
);
}