diff --git a/lib/6to5/transformation/transformers/es6-let-scoping.js b/lib/6to5/transformation/transformers/es6-let-scoping.js index 2f8978009e..a2e665abef 100644 --- a/lib/6to5/transformation/transformers/es6-let-scoping.js +++ b/lib/6to5/transformation/transformers/es6-let-scoping.js @@ -27,7 +27,7 @@ exports.VariableDeclaration = function (node) { isLet(node); }; -exports.For = function (node, parent, file, scope) { +exports.Loop = function (node, parent, file, scope) { var init = node.left || node.init; if (isLet(init)) { t.ensureBlock(node); @@ -49,7 +49,7 @@ exports.For = function (node, parent, file, scope) { }; exports.BlockStatement = function (block, parent, file, scope) { - if (!t.isFor(parent)) { + if (!t.isLoop(parent)) { var letScoping = new LetScoping(false, block, parent, file, scope); letScoping.run(); } @@ -58,19 +58,19 @@ exports.BlockStatement = function (block, parent, file, scope) { /** * Description * - * @param {Boolean|Node} forParent + * @param {Boolean|Node} loopParent * @param {Node} block * @param {Node} parent * @param {File} file * @param {Scope} scope */ -function LetScoping(forParent, block, parent, file, scope) { - this.forParent = forParent; - this.parent = parent; - this.scope = scope; - this.block = block; - this.file = file; +function LetScoping(loopParent, block, parent, file, scope) { + this.loopParent = loopParent; + this.parent = parent; + this.scope = scope; + this.block = block; + this.file = file; this.letReferences = {}; this.body = []; @@ -172,11 +172,11 @@ LetScoping.prototype.remap = function () { traverse(node, replace); }; - var forParent = this.forParent; - if (forParent) { - traverseReplace(forParent.right, forParent); - traverseReplace(forParent.test, forParent); - traverseReplace(forParent.update, forParent); + var loopParent = this.loopParent; + if (loopParent) { + traverseReplace(loopParent.right, loopParent); + traverseReplace(loopParent.test, loopParent); + traverseReplace(loopParent.update, loopParent); } traverse(block, replace); @@ -365,7 +365,7 @@ LetScoping.prototype.getLetReferences = function () { }); return false; - } else if (t.isFor(node)) { + } else if (t.isLoop(node)) { return false; } }); @@ -428,7 +428,7 @@ LetScoping.prototype.buildHas = function (ret, call) { t.variableDeclarator(ret, call) ])); - var forParent = this.forParent; + var loopParent = this.loopParent; var retCheck; var has = this.has; var cases = []; @@ -443,7 +443,7 @@ LetScoping.prototype.buildHas = function (ret, call) { if (has.hasBreak || has.hasContinue) { // ensure that the parent has a label as we're building a switch and we // need to be able to access it - var label = forParent.label = forParent.label || this.file.generateUidIdentifier("loop", this.scope); + var label = loopParent.label = loopParent.label || this.file.generateUidIdentifier("loop", this.scope); if (has.hasBreak) { cases.push(t.switchCase(t.literal("break"), [t.breakStatement(label)])); diff --git a/lib/6to5/types/alias-keys.json b/lib/6to5/types/alias-keys.json index 0dc76ee2b6..19cec9ca23 100644 --- a/lib/6to5/types/alias-keys.json +++ b/lib/6to5/types/alias-keys.json @@ -3,14 +3,14 @@ "BreakStatement": ["Statement"], "ContinueStatement": ["Statement"], "DebuggerStatement": ["Statement"], - "DoWhileStatement": ["Statement", "Loop", "With"], + "DoWhileStatement": ["Statement", "Loop", "While"], "IfStatement": ["Statement"], "ReturnStatement": ["Statement"], "SwitchStatement": ["Statement"], "ThrowStatement": ["Statement"], "TryStatement": ["Statement"], - "WhileStatement": ["Statement"], - "WithStatement": ["Statement", "Loop", "With"], + "WhileStatement": ["Statement", "Loop", "While"], + "WithStatement": ["Statement"], "EmptyStatement": ["Statement"], "LabeledStatement": ["Statement"], "VariableDeclaration": ["Statement", "Declaration"],