id summary reporter owner description type status priority milestone component version resolution keywords cc blockedby blocking 1343 createWidget Bug? ole_ersoy@… bill "Overview: The addChild method of MyWidget should throw an exception if the child is not of a valid widget type. I tested it as follows (The test html document and Javascript code are pasted at the end of the email): function testInvalidChildException() { var myWidgetInstance = dojo.widget.createWidget(""MyWidget"", {}); var button = dojo.widget.createWidget(""Button"", {}); alert(button.widgetType); try { myWidgetInstance.addChild(button); } catch(e) { //Test Passed } } Testing results in this error: 1. testMyWidget.html:testInvalidChildException had an error Error message is: ""[Exception... ""Component returned failure code: 0x80520012 (NS_ERROR_FILE_NOT_FOUND) [nsIXMLHttpRequest.send]"" nsresult: ""0x80520012 (NS_ERROR_FILE_NOT_FOUND)"" location: ""JS frame :: file:////home/ole/workspace/AExperiment/lib/dojo/dojo.js :: anonymous :: line 951"" data: no]"" However, if I add this element below the script block the test passes:
Here is the Test File: Resonance Accordion Testing
Here is the MyWidget widget. Note that the directory ""com"" is in the same root directory as ""lib"". And lib contains the ""dojo"" directory and the ""jsunit"" directory. Here is the MyWidget.js package: dojo.provide(""com.MyWidget""); dojo.require(""dojo.widget.HtmlWidget""); dojo.require(""dojo.widget.*""); dojo.widget.defineWidget( ""com.MyWidget"", dojo.widget.HtmlWidget, { widgetType: ""MyWidget"", isContainer: true, allowCollapse: false, templateString: ""
"", addChild: function(widget) { if (widget.widgetType != ""WidgetItem"") { dojo.debug(""The Widget Contains items that are not AccordionItem items""); throw InvalidChildException; } else { this.addWidgetAsDirectChild(widget); this.registerChild(widget); return widget; } }, postCreate: function() { var childBuffer = this.children; this.children=[]; dojo.html.removeChildren(this.domNode); dojo.lang.forEach(childBuffer, dojo.lang.hitch(this,""addChild"")); }, } ); InvalidChildException =new Error (""Invalid Child Widget""); " defect closed high 0.9 Widgets 0.3 wontfix