Skip to content

Commit

Permalink
Merge pull request #3146 from surveyjs/feature/issue-3145-setValue
Browse files Browse the repository at this point in the history
Fix: Clear setValue for setvalue trigger can produce exception #3145
  • Loading branch information
dmitry-kurmanov authored Jul 29, 2021
2 parents b938b6d + e2efee1 commit f831d1c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ export class Base {
*/
public setPropertyValue(name: string, val: any) {
var oldValue = this.getPropertyValue(name);
if (oldValue && Array.isArray(oldValue)) {
if (oldValue && Array.isArray(oldValue) && !!this.arraysInfo) {
if (this.isTwoValueEquals(oldValue, val)) return;
var arrayInfo = this.arraysInfo[name];
this.setArray(
Expand Down
7 changes: 7 additions & 0 deletions tests/basetests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,3 +484,10 @@ QUnit.test("Base onArrayChanged", function(assert) {
assert.equal(arrayChanges.index, 0, "added into 0 index");
assert.deepEqual(arrayChanges.itemsToAdd, [base.items[0]], "added items");
});
QUnit.test("Change value to array and then to undefined", function(assert) {
var base = new Base();
base.setPropertyValue("testValue", [1, 2, 3]);
assert.deepEqual(base.getPropertyValue("testValue"), [1, 2, 3]);
base.setPropertyValue("testValue", undefined);
assert.notOk(base.getPropertyValue("testValue"));
});

0 comments on commit f831d1c

Please sign in to comment.