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)