add callDelegate transformation helper - fixes #1064
This commit is contained in:
parent
ca79fff0c4
commit
b234603e24
11
src/babel/transformation/helpers/call-delegate.js
Normal file
11
src/babel/transformation/helpers/call-delegate.js
Normal file
@ -0,0 +1,11 @@
|
||||
import * as t from "../../types";
|
||||
|
||||
export default function (node) {
|
||||
var container = t.functionExpression(null, [], node.body, node.generator, node.async);
|
||||
container.shadow = true;
|
||||
|
||||
var call = t.callExpression(container, []);
|
||||
if (node.generator) call = t.yieldExpression(call, true);
|
||||
|
||||
return t.returnStatement(call);
|
||||
}
|
||||
@ -1,3 +1,4 @@
|
||||
import callDelegate from "../../helpers/call-delegate";
|
||||
import * as util from "../../../util";
|
||||
import * as t from "../../../types";
|
||||
|
||||
@ -91,11 +92,7 @@ exports.Function = function (node, parent, scope, file) {
|
||||
node.params = node.params.slice(0, lastNonDefaultParam);
|
||||
|
||||
if (state.iife) {
|
||||
var container = t.functionExpression(null, [], node.body, node.generator);
|
||||
container.shadow = true;
|
||||
|
||||
body.push(t.returnStatement(t.callExpression(container, [])));
|
||||
|
||||
body.push(callDelegate(node));
|
||||
node.body = t.blockStatement(body);
|
||||
} else {
|
||||
node.body.body = body.concat(node.body.body);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user