0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-29 04:42:41 +00:00

Add tests for cross-page behavior and fix related bugs

This commit is contained in:
Trevor Buckner
2024-02-20 22:31:33 -05:00
parent 9ad1d1f196
commit 6870fd6d76
2 changed files with 72 additions and 22 deletions

View File

@@ -380,15 +380,21 @@ const replaceVar = function(input, hoist=false, allowUnresolved=false) {
};
const lookupVar = function(label, index, hoist=false) {
if(hoist)
index = Object.keys(globalVarsList).length; // Move index to start from last page
while (index >= 0) {
if(globalVarsList[index]?.[label] !== undefined)
return globalVarsList[index][label];
index--;
}
if(hoist) { //If normal lookup failed, attempt hoisting
index = Object.keys(globalVarsList).length; // Move index to start from last page
while (index >= 0) {
if(globalVarsList[index]?.[label] !== undefined)
return globalVarsList[index][label];
index--;
}
}
return undefined;
};