add self-global template to runtime generation

This commit is contained in:
Sebastian McKenzie
2014-11-10 08:16:38 +11:00
parent e0d3e18865
commit b2ab0dbedc
2 changed files with 2 additions and 10 deletions

View File

@@ -11,16 +11,7 @@ module.exports = function (namespace) {
var container = t.functionExpression(null, [], t.blockStatement(body));
var tree = t.program([t.expressionStatement(t.callExpression(container, []))]);
body.push(t.variableDeclaration("var", [
t.variableDeclarator(t.identifier("self"), t.conditionalExpression(
t.binaryExpression("===",
t.unaryExpression("typeof", t.identifier("global"), true),
t.literal("undefined")
),
t.identifier("window"),
t.identifier("global"))
)
]));
body.push(util.template("self-global", true));
body.push(t.variableDeclaration("var", [
t.variableDeclarator(

View File

@@ -0,0 +1 @@
var self = typeof global === "undefined" ? window : global;