# HG changeset patch # User cin # Date 2021-10-24 23:00:19 # Node ID a842d051d22782ef1040e566b04bda54fd321cce # Parent a3547e80af287215af3e5147a46c7922f3f64a01 Corrected _addChild behavior for WidgetRendition when the content is FunctionRendition which returns a widget instance diff --git a/djx/src/main/ts/tsx/WidgetRendition.ts b/djx/src/main/ts/tsx/WidgetRendition.ts --- a/djx/src/main/ts/tsx/WidgetRendition.ts +++ b/djx/src/main/ts/tsx/WidgetRendition.ts @@ -1,7 +1,7 @@ import dom = require("dojo/dom-construct"); import { argumentNotNull } from "@implab/core-amd/safe"; import { RenditionBase } from "./RenditionBase"; -import { DojoNodePosition, isInPage, isWidget } from "./traits"; +import { DojoNodePosition, isElementNode, isInPage, isWidget } from "./traits"; import registry = require("dijit/registry"); import ContentPane = require("dijit/layout/ContentPane"); @@ -41,11 +41,18 @@ export class WidgetRendition extends Ren } else if (isWidget(child)) { instance.addChild(child); } else { - if (!instance.containerNode) - throw new Error("The widget doesn't have neither addChild nor containerNode"); + const childDom = this.getItemDom(child); + const w = isElementNode(childDom) ? registry.byNode(childDom) : undefined; - // the current widget isn't started, it's children shouldn't start too - dom.place(this.getItemDom(child), instance.containerNode); + if (w) { + instance.addChild(w); + } else { + if (!instance.containerNode) + throw new Error("Failed to add DOM content. The widget doesn't have a containerNode"); + + // the current widget isn't started, it's children shouldn't start too + dom.place(this.getItemDom(child), instance.containerNode); + } } } else { if (!instance.containerNode)