Opened 12 years ago

Closed 12 years ago

#9689 closed defect (wontfix)

dijit.findWidgets() returns "undefined" widgets

Reported by: yoava Owned by:
Priority: high Milestone: tbd
Component: Dijit Version: 1.3.2
Keywords: Cc:
Blocked By: Blocking:


Problem: Getting exception on window onunload.

Cause: getChildrenHelper() in dijit.findWidgets() finds all nodes with attribute "widgetId" and adds dijit.byId(widgetId) to return list.

But if (as in my case) pasreOnLoad is false and widget wasn't created for this node an "undefined" is added to return list (resulting in later "null-pointer" exception).

Solution: Check if dijit.byId(widgetId) has value before adding to list, as so:

var widgetId = node.getAttribute("widgetId");

if (widgetId) { var widget = dijit.byId(widgetId); if (widget) {



Change History (6)

comment:1 Changed 12 years ago by bill

Milestone: 1.4tbd

If a widget wasn't created then the node will have no widgetId attribute.

Please attach a test case.

comment:2 Changed 12 years ago by bill

Resolution: invalid
Status: newclosed

Closing for lack of test case, but please reopen if you have one (or write a comment here and I will reopen).

comment:3 Changed 12 years ago by yoava

Resolution: invalid
Status: closedreopened

comment:4 Changed 12 years ago by yoava

But I wrote the test case... As you said, the widget isn't created. Test Case:

  1. Add dojo with pasreOnLoad=false (instantiate widget yourself).
  2. Add a <div widgetId="someId">...</>
  3. The widget isn't created (yet, but other widgets are created)
  4. Call dijit.findWidgets() and get an exception (because widgetId attribute exists but no widget is created yet).


comment:5 Changed 12 years ago by bill

You need to write test cases as HTML files and attach them to this ticket using the attach file button. But anyway, it's illegal to have

<div widgetId="someId">...</>

in your markup. widgetId is a reserved attribute name that dijit uses internally and dijit will get confused if the original markup or any other code starts setting that attribute value.

comment:6 Changed 12 years ago by bill

Resolution: wontfix
Status: reopenedclosed

So anyway, you should just use id, like:

<div id="someId">

That will solve the error in dijit.findWidgets().

Note: See TracTickets for help on using tickets.