Skip to content

Commit

Permalink
Merge pull request surveyjs#3406 from surveyjs/feature/3398-warn-if-d…
Browse files Browse the repository at this point in the history
…isposed

Feature/3398 warn if disposed
  • Loading branch information
andrewtelnov authored Oct 1, 2021
2 parents e120eb9 + 9c4e038 commit 796b59c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"serve_ci": "http-server",
"test": "karma start ./build-scripts/karma.conf.js",
"testcafe": "concurrently \"http-server --silent\" \"testcafe -c 4 -q chrome testCafe/ --selector-timeout 1500 --reporter minimal\"",
"testcafe_file": "concurrently \"http-server --silent\" \"testcafe chrome testCafe/conditionsAndTriggers/completeTrigger.js --selector-timeout 1500 --reporter minimal\"",
"testcafe_file": "concurrently \"http-server --silent\" \"testcafe chrome testCafe/components/popup.ts --selector-timeout 1500 --reporter minimal\"",
"testcafe_ci": "http-server --silent & testcafe -q chrome:headless testCafe/ --reporter minimal",
"testcafe_sauce": "testcafe \"saucelabs:[email protected]:Windows 10\" testCafe/",
"release": "standard-version --message \"Release: %s [skip ci]\" ",
Expand Down
10 changes: 8 additions & 2 deletions src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,14 @@ export class Base {
return this.propertyHash["value"];
}
protected setPropertyValueCore(propertiesHash: any, name: string, val: any) {
if (this.setPropertyValueCoreHandler && !this.isDisposedValue)
this.setPropertyValueCoreHandler(propertiesHash, name, val);
if (this.setPropertyValueCoreHandler) {
if (!this.isDisposedValue) {
this.setPropertyValueCoreHandler(propertiesHash, name, val);
} else {
// eslint-disable-next-line no-console
console.warn("Attempt to set property '" + name + "' of a disposed object '" + this.getType() + "'");
}
}
else propertiesHash[name] = val;
}
protected get isEditingSurveyElement(): boolean {
Expand Down
2 changes: 1 addition & 1 deletion src/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5913,14 +5913,14 @@ export class SurveyModel extends SurveyElementCore
* Use this method to dispose survey model properly.
*/
public dispose() {
this.currentPage = null;
super.dispose();
this.editingObj = null;
if (!this.pages) return;
for (var i = 0; i < this.pages.length; i++) {
this.pages[i].dispose();
}
this.pages.splice(0, this.pages.length);
this.currentPage = null;
}
}

Expand Down
5 changes: 4 additions & 1 deletion testCafe/components/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ const json = {
};

const disposeSurvey = ClientFunction(framework => {
window["survey"].dispose();
if (framework === "vue") {
window["vueApp"].$destroy();
}
if (framework === "react") {
window["ReactDOM"].unmountComponentAtNode(document.getElementById("surveyElement"));
}
window["survey"].dispose();
});

const getElementClientRect = ClientFunction(selector => {
Expand Down

0 comments on commit 796b59c

Please sign in to comment.