mirror of https://github.com/espruino/BangleApps
stlapview: fix closure let-capture
parent
7bd8d4701a
commit
ca9bae78af
|
@ -95,7 +95,10 @@ function showMainMenu() {
|
|||
};
|
||||
|
||||
for (let lapFile of LAP_FILES) {
|
||||
mainMenu[fileNameToDateString(lapFile)] = () => view(lapFile);
|
||||
// `let` variables in JS have special behaviour in loops,
|
||||
// where capturing them captures that instance of the variable,
|
||||
// but for espruino we need to do a slightly older trick:
|
||||
mainMenu[fileNameToDateString(lapFile)] = ((lapFile) => () => view(lapFile))(lapFile);
|
||||
}
|
||||
|
||||
if (LAP_FILES.length == 0) {
|
||||
|
|
Loading…
Reference in New Issue