Skip to content

Commit

Permalink
Rework implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
dxvladislavvolkov committed Jul 23, 2024
1 parent ce43250 commit 3d48229
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions packages/devextreme-vue/src/core/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ function initBaseComponent() {
render(): VNode {
const thisComponent = this as any as IBaseComponent;
const children: VNode[] = [];
const dxClasses = pickOutDxClasses(this.$el);
if (thisComponent.$_config.cleanNested) {
thisComponent.$_config.cleanNested();
}
Expand All @@ -90,7 +91,7 @@ function initBaseComponent() {
return h(
'div',
{
...getAttrs(this.$attrs, this.dxClasses),
...getAttrs(this.$attrs, dxClasses),
},
children,
);
Expand Down Expand Up @@ -147,7 +148,6 @@ function initBaseComponent() {
const thisComponent = this as any as IBaseComponent;
const instance = thisComponent.$_instance;

this.dxClasses = [];
if (instance) {
triggerHandler(this.$el, DX_REMOVE_EVENT);
instance.dispose();
Expand Down Expand Up @@ -299,12 +299,15 @@ function cleanWidgetNode(node: Node) {
return removedNodes;
}

function pickOutDxClasses(el: Element, attr: any, dxClasses: string[]) {
el.classList.forEach((item: string) => {
if (attr.class && attr.class.indexOf(item) === -1) {
dxClasses.push(item);
function pickOutDxClasses(el: Element) {
const actualDxClasses: string[] = [];
el && el.classList.forEach((item: string) => {
if (item.startsWith('dx-')) {
actualDxClasses.push(item);
}
});

return actualDxClasses;
}

function restoreNodes(el: Element, nodes: Element[]) {
Expand Down Expand Up @@ -340,9 +343,7 @@ function initDxComponent() {

this.$_createWidget(this.$el);
thisComponent.$_instance.endUpdate();

restoreNodes(this.$el, nodes);
pickOutDxClasses(this.$el, this.$attrs, this.dxClasses);

if (this.$slots && this.$slots.default) {
getChildren(thisComponent).forEach((child: VNode) => {
Expand Down

0 comments on commit 3d48229

Please sign in to comment.