From fda8ed1ece638341f39e7e6381f38301a00af326 Mon Sep 17 00:00:00 2001 From: Nils Knappmeier Date: Fri, 4 Aug 2023 22:59:35 +0200 Subject: [PATCH] refactor: rename i to startPartIndex --- lib/handlebars/compiler/javascript-compiler.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/handlebars/compiler/javascript-compiler.js b/lib/handlebars/compiler/javascript-compiler.js index 678b42b0..5a86e9a0 100644 --- a/lib/handlebars/compiler/javascript-compiler.js +++ b/lib/handlebars/compiler/javascript-compiler.js @@ -534,16 +534,22 @@ JavaScriptCompiler.prototype = { this.resolvePath('data', parts, 0, true, strict); }, - resolvePath: function (type, parts, i, falsy, strict) { + resolvePath: function (type, parts, startPartIndex, falsy, strict) { if (this.options.strict || this.options.assumeObjects) { this.push( - strictLookup(this.options.strict && strict, this, parts, i, type) + strictLookup( + this.options.strict && strict, + this, + parts, + startPartIndex, + type + ) ); return; } let len = parts.length; - for (; i < len; i++) { + for (let i = startPartIndex; i < len; i++) { /* eslint-disable no-loop-func */ this.replaceStack((current) => { let lookup = this.nameLookup(current, parts[i], type); @@ -1155,14 +1161,14 @@ JavaScriptCompiler.isValidJavaScriptVariableName = function (name) { ); }; -function strictLookup(requireTerminal, compiler, parts, i, type) { +function strictLookup(requireTerminal, compiler, parts, startPartIndex, type) { let stack = compiler.popStack(), len = parts.length; if (requireTerminal) { len--; } - for (; i < len; i++) { + for (let i = startPartIndex; i < len; i++) { stack = compiler.nameLookup(stack, parts[i], type); } @@ -1172,7 +1178,7 @@ function strictLookup(requireTerminal, compiler, parts, i, type) { '(', stack, ', ', - compiler.quotedString(parts[i]), + compiler.quotedString(parts[len]), ', ', JSON.stringify(compiler.source.currentLocation), ' )',