Skip to content

fromJSON() with validatePropertyValues: true produces an error when the choices property is defined as a function that references the object instance #10818

@andrewtelnov

Description

@andrewtelnov

The following code will produce the "cannot read property of null" JS error:

  Serializer.addProperty("question", { name: "prop1", choices: (obj: Base) => {
    return obj.getType() === "text" ? [1, 2, 3] : [4, 5, 6];
  } });
  const survey = new SurveyModel();
  survey.fromJSON({
    elements: [
      { type: "text", name: "q1", prop1: 2 },
      { type: "checkbox", name: "q2", prop1: 5 }
    ]
  }, { validatePropertyValues: true });

Metadata

Metadata

Assignees

Labels

buguser issueAn issue or bug reported by users

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions