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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jspsych",
3
- "version": "7.3.1",
3
+ "version": "7.3.2",
4
4
  "description": "Behavioral experiments in a browser",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
package/src/JsPsych.ts CHANGED
@@ -781,7 +781,14 @@ export class JsPsych {
781
781
  for (const param in trial.type.info.parameters) {
782
782
  // check if parameter is complex with nested defaults
783
783
  if (trial.type.info.parameters[param].type === ParameterType.COMPLEX) {
784
- if (trial.type.info.parameters[param].array === true) {
784
+ // check if parameter is undefined and has a default value
785
+ if (typeof trial[param] === "undefined" && trial.type.info.parameters[param].default) {
786
+ trial[param] = trial.type.info.parameters[param].default;
787
+ }
788
+ // if parameter is an array, iterate over each entry after confirming that there are
789
+ // entries to iterate over. this is common when some parameters in a COMPLEX type have
790
+ // default values and others do not.
791
+ if (trial.type.info.parameters[param].array === true && Array.isArray(trial[param])) {
785
792
  // iterate over each entry in the array
786
793
  trial[param].forEach(function (ip, i) {
787
794
  // check each parameter in the plugin description
@@ -789,13 +796,7 @@ export class JsPsych {
789
796
  if (typeof trial[param][i][p] === "undefined" || trial[param][i][p] === null) {
790
797
  if (typeof trial.type.info.parameters[param].nested[p].default === "undefined") {
791
798
  console.error(
792
- "You must specify a value for the " +
793
- p +
794
- " parameter (nested in the " +
795
- param +
796
- " parameter) in the " +
797
- trial.type +
798
- " plugin."
799
+ `You must specify a value for the ${p} parameter (nested in the ${param} parameter) in the ${trial.type.info.name} plugin.`
799
800
  );
800
801
  } else {
801
802
  trial[param][i][p] = trial.type.info.parameters[param].nested[p].default;
@@ -809,11 +810,7 @@ export class JsPsych {
809
810
  else if (typeof trial[param] === "undefined" || trial[param] === null) {
810
811
  if (typeof trial.type.info.parameters[param].default === "undefined") {
811
812
  console.error(
812
- "You must specify a value for the " +
813
- param +
814
- " parameter in the " +
815
- trial.type.info.name +
816
- " plugin."
813
+ `You must specify a value for the ${param} parameter in the ${trial.type.info.name} plugin.`
817
814
  );
818
815
  } else {
819
816
  trial[param] = trial.type.info.parameters[param].default;