Fix class instance access in callback functions

by converting the affected functions to arrow functions to preserve the
outer-scope `this`
This commit is contained in:
bjoluc 2021-08-20 14:17:46 +02:00
parent ba9c495a21
commit bb141c446a
2 changed files with 2 additions and 2 deletions

View File

@ -9,7 +9,7 @@ export class HardwareAPI {
//it might be useful to open up a line of communication from the extension back to this page //it might be useful to open up a line of communication from the extension back to this page
//script, again, this will have to pass through DOM events. For now speed is of no concern so I //script, again, this will have to pass through DOM events. For now speed is of no concern so I
//will use jQuery //will use jQuery
document.addEventListener("jspsych-activate", function (evt) { document.addEventListener("jspsych-activate", (evt) => {
this.hardwareConnected = true; this.hardwareConnected = true;
}); });
} }

View File

@ -27,7 +27,7 @@ export class MediaAPI {
} }
getAudioBuffer(audioID) { getAudioBuffer(audioID) {
return new Promise(function (resolve, reject) { return new Promise((resolve, reject) => {
// check whether audio file already preloaded // check whether audio file already preloaded
if ( if (
typeof this.audio_buffers[audioID] == "undefined" || typeof this.audio_buffers[audioID] == "undefined" ||