From bb141c446a24f07b42dbc7d37580dfc66a72dc34 Mon Sep 17 00:00:00 2001 From: bjoluc Date: Fri, 20 Aug 2021 14:17:46 +0200 Subject: [PATCH] Fix class instance access in callback functions by converting the affected functions to arrow functions to preserve the outer-scope `this` --- packages/jspsych/src/modules/plugin-api/HardwareAPI.ts | 2 +- packages/jspsych/src/modules/plugin-api/MediaAPI.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/jspsych/src/modules/plugin-api/HardwareAPI.ts b/packages/jspsych/src/modules/plugin-api/HardwareAPI.ts index ed4b1726..3929c83d 100644 --- a/packages/jspsych/src/modules/plugin-api/HardwareAPI.ts +++ b/packages/jspsych/src/modules/plugin-api/HardwareAPI.ts @@ -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 //script, again, this will have to pass through DOM events. For now speed is of no concern so I //will use jQuery - document.addEventListener("jspsych-activate", function (evt) { + document.addEventListener("jspsych-activate", (evt) => { this.hardwareConnected = true; }); } diff --git a/packages/jspsych/src/modules/plugin-api/MediaAPI.ts b/packages/jspsych/src/modules/plugin-api/MediaAPI.ts index 9eb83d3e..47310bff 100644 --- a/packages/jspsych/src/modules/plugin-api/MediaAPI.ts +++ b/packages/jspsych/src/modules/plugin-api/MediaAPI.ts @@ -27,7 +27,7 @@ export class MediaAPI { } getAudioBuffer(audioID) { - return new Promise(function (resolve, reject) { + return new Promise((resolve, reject) => { // check whether audio file already preloaded if ( typeof this.audio_buffers[audioID] == "undefined" ||