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.cjs CHANGED
@@ -71,7 +71,7 @@ var autoBind = (self, {include, exclude} = {}) => {
71
71
  return self;
72
72
  };
73
73
 
74
- var version = "7.3.1";
74
+ var version = "7.3.2";
75
75
 
76
76
  class MigrationError extends Error {
77
77
  constructor(message = "The global `jsPsych` variable is no longer available in jsPsych v7.") {
@@ -3189,20 +3189,21 @@ class JsPsych {
3189
3189
  for (const param in trial.type.info.parameters) {
3190
3190
  // check if parameter is complex with nested defaults
3191
3191
  if (trial.type.info.parameters[param].type === exports.ParameterType.COMPLEX) {
3192
- if (trial.type.info.parameters[param].array === true) {
3192
+ // check if parameter is undefined and has a default value
3193
+ if (typeof trial[param] === "undefined" && trial.type.info.parameters[param].default) {
3194
+ trial[param] = trial.type.info.parameters[param].default;
3195
+ }
3196
+ // if parameter is an array, iterate over each entry after confirming that there are
3197
+ // entries to iterate over. this is common when some parameters in a COMPLEX type have
3198
+ // default values and others do not.
3199
+ if (trial.type.info.parameters[param].array === true && Array.isArray(trial[param])) {
3193
3200
  // iterate over each entry in the array
3194
3201
  trial[param].forEach(function (ip, i) {
3195
3202
  // check each parameter in the plugin description
3196
3203
  for (const p in trial.type.info.parameters[param].nested) {
3197
3204
  if (typeof trial[param][i][p] === "undefined" || trial[param][i][p] === null) {
3198
3205
  if (typeof trial.type.info.parameters[param].nested[p].default === "undefined") {
3199
- console.error("You must specify a value for the " +
3200
- p +
3201
- " parameter (nested in the " +
3202
- param +
3203
- " parameter) in the " +
3204
- trial.type +
3205
- " plugin.");
3206
+ console.error(`You must specify a value for the ${p} parameter (nested in the ${param} parameter) in the ${trial.type.info.name} plugin.`);
3206
3207
  }
3207
3208
  else {
3208
3209
  trial[param][i][p] = trial.type.info.parameters[param].nested[p].default;
@@ -3215,11 +3216,7 @@ class JsPsych {
3215
3216
  // if it's not nested, checking is much easier and do that here:
3216
3217
  else if (typeof trial[param] === "undefined" || trial[param] === null) {
3217
3218
  if (typeof trial.type.info.parameters[param].default === "undefined") {
3218
- console.error("You must specify a value for the " +
3219
- param +
3220
- " parameter in the " +
3221
- trial.type.info.name +
3222
- " plugin.");
3219
+ console.error(`You must specify a value for the ${param} parameter in the ${trial.type.info.name} plugin.`);
3223
3220
  }
3224
3221
  else {
3225
3222
  trial[param] = trial.type.info.parameters[param].default;