diff --git a/lib/handlebars/compiler/javascript-compiler.js b/lib/handlebars/compiler/javascript-compiler.js index 7762412e..9a9cdd12 100644 --- a/lib/handlebars/compiler/javascript-compiler.js +++ b/lib/handlebars/compiler/javascript-compiler.js @@ -535,16 +535,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); @@ -1263,14 +1269,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); } @@ -1280,7 +1286,7 @@ function strictLookup(requireTerminal, compiler, parts, i, type) { '(', stack, ', ', - compiler.quotedString(parts[i]), + compiler.quotedString(parts[len]), ', ', JSON.stringify(compiler.source.currentLocation), ' )'