Skip to content

Commit 39ef5ab

Browse files
Restore only configurations components (#324)
* Restore only configurations components * Fix lint * Refactoring
1 parent 2b093de commit 39ef5ab

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/core/component.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -264,21 +264,23 @@ const BaseComponent: VueConstructor<IBaseComponent> = Vue.extend({
264264
});
265265

266266
function cleanWidgetNode(node: Node) {
267+
const removedNodes: Element[] = [];
267268
forEachChildNode(node, (childNode: Element) => {
268269
const parent = childNode.parentNode;
269270
const isExtension = childNode.hasAttribute && childNode.hasAttribute("isExtension");
270271
if ((childNode.nodeName === "#comment" || isExtension) && parent) {
272+
removedNodes.push(childNode);
271273
parent.removeChild(childNode);
272274
}
273275
});
276+
277+
return removedNodes;
274278
}
275279

276-
function restoreNodes(el: Element, nodes: Record<number, ChildNode>) {
277-
for (const key in nodes) {
278-
if (nodes.hasOwnProperty(key)) {
279-
el.appendChild(nodes[key]);
280-
}
281-
}
280+
function restoreNodes(el: Element, nodes: Element[]) {
281+
nodes.forEach((node) => {
282+
el.appendChild(node);
283+
});
282284
}
283285

284286
const DxComponent: VueConstructor = BaseComponent.extend({
@@ -301,8 +303,7 @@ const DxComponent: VueConstructor = BaseComponent.extend({
301303
},
302304

303305
mounted(): void {
304-
const nodes = {...this.$el.childNodes};
305-
cleanWidgetNode(this.$el);
306+
const nodes = cleanWidgetNode(this.$el);
306307

307308
this.$_createWidget(this.$el);
308309
this.$_instance.endUpdate();

0 commit comments

Comments
 (0)