diff --git a/packages/core/src/dom_components/model/Component.ts b/packages/core/src/dom_components/model/Component.ts index 1b1cb6e23..5708822a3 100644 --- a/packages/core/src/dom_components/model/Component.ts +++ b/packages/core/src/dom_components/model/Component.ts @@ -681,7 +681,7 @@ export default class Component extends StyleableModel { const areStaticAttributes = DynamicValueWatcher.areStaticValues(attrs); const evaluatedAttributes = areStaticAttributes ? attrs : DynamicValueWatcher.getStaticValues(attrs, this.em); this.componentDVListener.setAttributes(attrs); - this.set('attributes', evaluatedAttributes, opts); + this.set('attributes', { ...evaluatedAttributes }, opts); return this; } @@ -1304,14 +1304,15 @@ export default class Component extends StyleableModel { * @ts-ignore */ clone(opt: { symbol?: boolean; symbolInv?: boolean } = {}): this { const em = this.em; - const attr = { ...this.attributes }; + const attr = { + ...this.componentDVListener.getPropsDefsOrValues(this.attributes), + }; const opts = { ...this.opt }; const id = this.getId(); const cssc = em?.Css; attr.attributes = { ...(attr.attributes ? this.componentDVListener.getAttributesDefsOrValues(attr.attributes) : undefined), }; - delete attr.attributes.id; // @ts-ignore attr.components = []; // @ts-ignore @@ -1569,6 +1570,7 @@ export default class Component extends StyleableModel { let obj = Model.prototype.toJSON.call(this, opts); obj = { ...obj, ...this.componentDVListener.getDynamicPropsDefs() }; obj.attributes = this.componentDVListener.getAttributesDefsOrValues(this.getAttributes({ noClass: true })); + delete obj.componentDVListener; delete obj.traits; delete obj.attributes.class; delete obj.toolbar; diff --git a/packages/core/src/dom_components/model/ComponentDynamicValueListener.ts b/packages/core/src/dom_components/model/ComponentDynamicValueListener.ts index 0aa163122..6086b7594 100644 --- a/packages/core/src/dom_components/model/ComponentDynamicValueListener.ts +++ b/packages/core/src/dom_components/model/ComponentDynamicValueListener.ts @@ -59,4 +59,8 @@ export class ComponentDynamicValueListener { getAttributesDefsOrValues(attributes: ObjectAny) { return this.attributeWatchClass.getSerializableValues(attributes); } + + getPropsDefsOrValues(props: ObjectAny) { + return this.propertyWatchClass.getSerializableValues(props); + } }