Skip to content

Commit

Permalink
Do not use bind for callbacks that need to call session.getValue() up…
Browse files Browse the repository at this point in the history
…on callback time
  • Loading branch information
mfelsche committed Oct 7, 2024
1 parent da46d88 commit 552afae
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions static/web.js
Original file line number Diff line number Diff line change
Expand Up @@ -760,11 +760,16 @@
delete transposeletters.bindKey;
editor.commands.addCommand(transposeletters);

asmButton.onclick = compile.bind(window, "asm", result, session.getValue(), asmButton);

irButton.onclick = compile.bind(window, "llvm-ir", result, session.getValue(), irButton);

gistButton.onclick = shareGist.bind(window, result, session.getValue(), gistButton);
// do not use .bind() here, as the call to `session.getValue()` needs to be delayed until the actual click
asmButton.onclick = function() {
compile("asm", result, session.getValue(), asmButton);
};
irButton.onclick = function() {
compile("llvm-ir", result, session.getValue(), irButton);
};
gistButton.onclick = function() {
shareGist(result, session.getValue(), gistButton);
};

configureEditorButton.onclick = function () {
const dropdown = configureEditorButton.nextElementSibling;
Expand All @@ -773,11 +778,15 @@

clearResultButton.onclick = clear_result.bind(window, result);

themes.onkeyup = themes.onchange = set_theme.bind(window, editor, themelist, themes.options[themes.selectedIndex].text);
// not sure, if .bind() could be used here, just for good measure
themes.onkeyup = themes.onchange = function() {
set_theme(editor, themelist, themes.options[themes.selectedIndex].text);
};
}, false);
}());



// called via javascript:fn events from formatCompilerOutput
var old_range;

Expand Down

0 comments on commit 552afae

Please sign in to comment.