##// END OF EJS Templates
Corrected _addChild behavior for WidgetRendition when the content is FunctionRendition which returns a widget instance
cin -
r91:a842d051d227 default
parent child
Show More
@@ -1,7 +1,7
1 import dom = require("dojo/dom-construct");
1 import dom = require("dojo/dom-construct");
2 import { argumentNotNull } from "@implab/core-amd/safe";
2 import { argumentNotNull } from "@implab/core-amd/safe";
3 import { RenditionBase } from "./RenditionBase";
3 import { RenditionBase } from "./RenditionBase";
4 import { DojoNodePosition, isInPage, isWidget } from "./traits";
4 import { DojoNodePosition, isElementNode, isInPage, isWidget } from "./traits";
5 import registry = require("dijit/registry");
5 import registry = require("dijit/registry");
6 import ContentPane = require("dijit/layout/ContentPane");
6 import ContentPane = require("dijit/layout/ContentPane");
7
7
@@ -41,12 +41,19 export class WidgetRendition extends Ren
41 } else if (isWidget(child)) {
41 } else if (isWidget(child)) {
42 instance.addChild(child);
42 instance.addChild(child);
43 } else {
43 } else {
44 const childDom = this.getItemDom(child);
45 const w = isElementNode(childDom) ? registry.byNode(childDom) : undefined;
46
47 if (w) {
48 instance.addChild(w);
49 } else {
44 if (!instance.containerNode)
50 if (!instance.containerNode)
45 throw new Error("The widget doesn't have neither addChild nor containerNode");
51 throw new Error("Failed to add DOM content. The widget doesn't have a containerNode");
46
52
47 // the current widget isn't started, it's children shouldn't start too
53 // the current widget isn't started, it's children shouldn't start too
48 dom.place(this.getItemDom(child), instance.containerNode);
54 dom.place(this.getItemDom(child), instance.containerNode);
49 }
55 }
56 }
50 } else {
57 } else {
51 if (!instance.containerNode)
58 if (!instance.containerNode)
52 throw new Error("The widget doesn't have neither addChild nor containerNode");
59 throw new Error("The widget doesn't have neither addChild nor containerNode");
General Comments 0
You need to be logged in to leave comments. Login now