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:
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user