Skip to content

Commit

Permalink
set dxclasses when resetting the custom class
Browse files Browse the repository at this point in the history
  • Loading branch information
dxvladislavvolkov committed Dec 11, 2024
1 parent 1f664c8 commit 6fab520
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 24 additions & 0 deletions packages/devextreme-vue/src/core/__tests__/textbox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,28 @@ describe('two-way binding', () => {
expect(component.element.classList.toString()).toBe('custom2 dx-show-invalid-badge dx-textbox dx-texteditor dx-editor-outlined dx-texteditor-empty dx-widget');
});
});

it('dxClass should be set when class attr is undefined', async () => {
expect.assertions(1);
const vm = defineComponent({
template:
`<dx-text-box id="component" :class="{custom: customClass}"></dx-text-box>
`,
components: {
DxTextBox,
},
props: {
customClass: {
type: String,
default: true,
},
},
});
const wrapper = mount(vm);
const component = wrapper.getComponent('#component');
await wrapper.setProps({ customClass: false });
await nextTick(() => {
expect(component.element.classList.toString()).toBe(' dx-show-invalid-badge dx-textbox dx-texteditor dx-editor-outlined dx-texteditor-empty dx-widget');
});
});
});
2 changes: 1 addition & 1 deletion packages/devextreme-vue/src/core/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function getAttrs(attrs, dxClasses: string[]) {
const attributes = {};
includeAttrs.forEach((attr) => {
const attrValue = attrs[attr];
if (attrValue) {
if (attrValue !== undefined && attrValue !== null) {
attributes[attr] = attr === 'class' && dxClasses.length ? `${attrValue} ${dxClasses.join(' ')}` : attrValue;
}
});
Expand Down

0 comments on commit 6fab520

Please sign in to comment.