From 6b6f52e49dc7a35fe5d29bb9c2f85979df1a6094 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Sat, 15 Nov 2025 03:40:43 +0400 Subject: [PATCH] Fix attributes/styles collide in data sources --- .../domain_abstract/model/StyleableModel.ts | 6 +- .../data_sources/dynamic_values/attributes.ts | 57 +++++++++++++++++++ 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/packages/core/src/domain_abstract/model/StyleableModel.ts b/packages/core/src/domain_abstract/model/StyleableModel.ts index 8e3bca8b8..36005186f 100644 --- a/packages/core/src/domain_abstract/model/StyleableModel.ts +++ b/packages/core/src/domain_abstract/model/StyleableModel.ts @@ -182,9 +182,9 @@ export default class StyleableModel ex return; } }); - const resolvedProps = this.dataResolverWatchers.addProps({ style: newStyle }, opts) as Partial; - this.set(resolvedProps, opts as any); - newStyle = resolvedProps['style']! as StyleProps; + + this.set({ style: newStyle }, opts); + newStyle = this.attributes['style'] as StyleProps; const changedKeys = Object.keys(shallowDiff(propOrig, propNew)); const diff: ObjectAny = changedKeys.reduce((acc, key) => { diff --git a/packages/core/test/specs/data_sources/dynamic_values/attributes.ts b/packages/core/test/specs/data_sources/dynamic_values/attributes.ts index 61d1ae65d..feebb7b65 100644 --- a/packages/core/test/specs/data_sources/dynamic_values/attributes.ts +++ b/packages/core/test/specs/data_sources/dynamic_values/attributes.ts @@ -240,6 +240,63 @@ describe('Dynamic Attributes', () => { const input = cmp.getEl(); expect(input?.getAttribute('dynamicAttribute')).toBe(null); }); + + test('attributes should not collide with styles', () => { + ({ em, dsm, cmpRoot } = setupTestEditor({ config: { avoidInlineStyle: false } })); + dsm.add({ + id: 'ds_id', + records: [ + { id: 'id1', value: 'test-value' }, + { id: 'id2', value: 'second-test-value' }, + ], + }); + + const cmp = cmpRoot.append({ + tagName: 'input', + })[0]; + + cmp.addAttributes({ + static: 'static-value-attr', + dynamic: { + type: DataVariableType, + defaultValue: 'default', + path: 'ds_id.id1.value', + }, + }); + cmp.addStyle({ + static: 'static-value-style', + dynamic: { + type: DataVariableType, + defaultValue: 'default', + path: 'ds_id.id2.value', + }, + }); + + testAttribute(cmp, 'style', 'static:static-value-style;dynamic:second-test-value;'); + testAttribute(cmp, 'dynamic', 'test-value'); + testAttribute(cmp, 'static', 'static-value-attr'); + + cmp.addAttributes({ + static: 'static-value-attr-2', + dynamic: { + type: DataVariableType, + defaultValue: 'default', + path: 'ds_id.id2.value', + }, + }); + cmp.addStyle({ + static: 'static-value-style-2', + dynamic: { + type: DataVariableType, + defaultValue: 'default', + path: 'ds_id.id1.value', + }, + }); + + testAttribute(cmp, 'style', 'static:static-value-style-2;dynamic:test-value;'); + testAttribute(cmp, 'dynamic', 'second-test-value'); + testAttribute(cmp, 'static', 'static-value-attr-2'); + }); }); function changeDataSourceValue(dsm: DataSourceManager, id: string) {