From 33980f748b87dd80d344d71c0ebe73523d794fd4 Mon Sep 17 00:00:00 2001 From: mohamedsalem401 Date: Wed, 11 Dec 2024 04:12:21 +0200 Subject: [PATCH] fix component properties continue to watch old dynamic variables --- .../dom_components/model/ComponentDynamicValueListener.ts | 1 + .../core/src/dom_components/model/DynamicValueWatcher.ts | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/core/src/dom_components/model/ComponentDynamicValueListener.ts b/packages/core/src/dom_components/model/ComponentDynamicValueListener.ts index 7963205ae..0aa163122 100644 --- a/packages/core/src/dom_components/model/ComponentDynamicValueListener.ts +++ b/packages/core/src/dom_components/model/ComponentDynamicValueListener.ts @@ -35,6 +35,7 @@ export class ComponentDynamicValueListener { } watchProps(props: ObjectAny) { + this.propertyWatchClass.removeListeners(Object.keys(props)); this.propertyWatchClass.watchDynamicValue(props); } diff --git a/packages/core/src/dom_components/model/DynamicValueWatcher.ts b/packages/core/src/dom_components/model/DynamicValueWatcher.ts index 0e5c77b5f..2aaa121c0 100644 --- a/packages/core/src/dom_components/model/DynamicValueWatcher.ts +++ b/packages/core/src/dom_components/model/DynamicValueWatcher.ts @@ -72,7 +72,12 @@ export class DynamicValueWatcher { */ removeListeners(keys?: string[]) { const propsKeys = keys ? keys : Object.keys(this.dynamicVariableListeners); - propsKeys.forEach((key) => this.dynamicVariableListeners[key].destroy()); + propsKeys.forEach((key) => { + if (this.dynamicVariableListeners[key]) { + this.dynamicVariableListeners[key].destroy(); + delete this.dynamicVariableListeners[key]; + } + }); } getSerializableValues(values: ObjectAny) {