Skip to content

Commit 0be0949

Browse files
committed
#6045 Scoped vdom trees: manager.Component: getVdomRenderTree()
1 parent 77aebd7 commit 0be0949

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

src/component/Base.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2206,7 +2206,7 @@ class Base extends CoreBase {
22062206
parentId : autoMount ? me.getMountedParentId() : undefined,
22072207
parentIndex: autoMount ? me.getMountedParentIndex() : undefined,
22082208
windowId : me.windowId,
2209-
...me.vdom
2209+
...ComponentManager.getVdomRenderTree(me.vdom)
22102210
});
22112211

22122212
me.onRender(data, useVdomWorker ? autoMount : false);

src/manager/Component.mjs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,29 @@ class Component extends Base {
318318
return parents
319319
}
320320

321+
/**
322+
* Copies a given vdom tree and replaces child component references with the vdom of their matching components
323+
* @param {Object} vdom
324+
* @returns {Object}
325+
*/
326+
getVdomRenderTree(vdom) {
327+
let output = Neo.clone(vdom);
328+
329+
if (vdom.cn) {
330+
output.cn = [];
331+
332+
vdom.cn.forEach(item => {
333+
if (item.componentId) {
334+
item = this.get(item.componentId).vdom
335+
}
336+
337+
output.cn.push(this.getVdomRenderTree(item))
338+
})
339+
}
340+
341+
return output
342+
}
343+
321344
/**
322345
* Check if the component had a property of any value somewhere in the Prototype chain
323346
*

0 commit comments

Comments
 (0)