add self-global template to runtime generation
This commit is contained in:
@@ -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(
|
||||
|
||||
1
lib/6to5/templates/self-global.js
Normal file
1
lib/6to5/templates/self-global.js
Normal file
@@ -0,0 +1 @@
|
||||
var self = typeof global === "undefined" ? window : global;
|
||||
Reference in New Issue
Block a user