jspsych 7.3.1 → 7.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -67,7 +67,7 @@ var autoBind = (self, {include, exclude} = {}) => {
67
67
  return self;
68
68
  };
69
69
 
70
- var version = "7.3.1";
70
+ var version = "7.3.2";
71
71
 
72
72
  class MigrationError extends Error {
73
73
  constructor(message = "The global `jsPsych` variable is no longer available in jsPsych v7.") {
@@ -3185,20 +3185,21 @@ class JsPsych {
3185
3185
  for (const param in trial.type.info.parameters) {
3186
3186
  // check if parameter is complex with nested defaults
3187
3187
  if (trial.type.info.parameters[param].type === ParameterType.COMPLEX) {
3188
- if (trial.type.info.parameters[param].array === true) {
3188
+ // check if parameter is undefined and has a default value
3189
+ if (typeof trial[param] === "undefined" && trial.type.info.parameters[param].default) {
3190
+ trial[param] = trial.type.info.parameters[param].default;
3191
+ }
3192
+ // if parameter is an array, iterate over each entry after confirming that there are
3193
+ // entries to iterate over. this is common when some parameters in a COMPLEX type have
3194
+ // default values and others do not.
3195
+ if (trial.type.info.parameters[param].array === true && Array.isArray(trial[param])) {
3189
3196
  // iterate over each entry in the array
3190
3197
  trial[param].forEach(function (ip, i) {
3191
3198
  // check each parameter in the plugin description
3192
3199
  for (const p in trial.type.info.parameters[param].nested) {
3193
3200
  if (typeof trial[param][i][p] === "undefined" || trial[param][i][p] === null) {
3194
3201
  if (typeof trial.type.info.parameters[param].nested[p].default === "undefined") {
3195
- console.error("You must specify a value for the " +
3196
- p +
3197
- " parameter (nested in the " +
3198
- param +
3199
- " parameter) in the " +
3200
- trial.type +
3201
- " plugin.");
3202
+ console.error(`You must specify a value for the ${p} parameter (nested in the ${param} parameter) in the ${trial.type.info.name} plugin.`);
3202
3203
  }
3203
3204
  else {
3204
3205
  trial[param][i][p] = trial.type.info.parameters[param].nested[p].default;
@@ -3211,11 +3212,7 @@ class JsPsych {
3211
3212
  // if it's not nested, checking is much easier and do that here:
3212
3213
  else if (typeof trial[param] === "undefined" || trial[param] === null) {
3213
3214
  if (typeof trial.type.info.parameters[param].default === "undefined") {
3214
- console.error("You must specify a value for the " +
3215
- param +
3216
- " parameter in the " +
3217
- trial.type.info.name +
3218
- " plugin.");
3215
+ console.error(`You must specify a value for the ${param} parameter in the ${trial.type.info.name} plugin.`);
3219
3216
  }
3220
3217
  else {
3221
3218
  trial[param] = trial.type.info.parameters[param].default;