Skip to content

Commit

Permalink
refactor: rename i to startPartIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
nknapp committed Aug 4, 2023
1 parent 520e1d5 commit 6abdd10
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions lib/handlebars/compiler/javascript-compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

Expand All @@ -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),
' )'
Expand Down

0 comments on commit 6abdd10

Please sign in to comment.