Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set dxclasses when resetting the custom class #28539

Open
wants to merge 2 commits into
base: 24_1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading