refactor: rename i to startPartIndex

This commit is contained in:
Nils Knappmeier
2023-08-04 22:59:35 +02:00
committed by Jay Linski
parent 99d162cadc
commit d3b93571a7
+12 -6
View File
@@ -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),
' )',