Opened 15 years ago

Closed 14 years ago

#3211 closed defect (fixed)

Can not create a ContentPane without source node

Reported by: guest Owned by: bill
Priority: high Milestone: 1.0
Component: Dijit Version: 0.9
Keywords: Cc: bill
Blocked By: Blocking:


It is not possible to create a new ContentPane? without source node.

// this throws no error
var div1 = document.createElement("div");
var newCp = new dijit.layout.ContentPane({id:"newCp"}, div1);

// this throws an error
var tmp = new dijit.layout.ContentPane({id:"newCp3"} );

I tested some other widgets and can create them without the source node.

Change History (8)

comment:1 Changed 15 years ago by bill

Owner: changed from bill to mumme

comment:2 Changed 15 years ago by mumme

Cc: bill added

Ok due to the way dijit._Widget is set up it means this fix would have to go in dijit._Widget constructor function. At least thats the only way I see it (without bloat in ContentPane? regarding -> etc.).

That means we will always create a DIV if srcNodeRef isn't present. It is a simple 1 liner fix, but it might be bad for runtime on some other widgets.

--- _Widget.js  (revision 9539)
+++ _Widget.js  (working copy)
@@ -28,8 +28,8 @@
        //                              a stub function that you can over-ride to modify take
        //                              actions once the widget has been placed in the UI

-       // store pointer to original dom tree
-       this.srcNodeRef = dojo.byId(srcNodeRef);
+       // store pointer to original dom tree, or create a new DIV if none is supplied
+       this.srcNodeRef = dojo.byId(srcNodeRef || dojo.doc.createElement('div'));

        // For garbage collection.  An array of handles returned by Widget.connect()
        // Each handle returned from Widget.connect() is an array of handles from dojo.connect()

Question is should we really support automagical domNode construction in 0.9?

comment:3 Changed 15 years ago by bill

Milestone: 0.91.0

Right, it's like you said. Most widgets don't have this issue because most widgets have templates. As for that one line fix, it's a little inefficient because for widgets with templates it's unnecessary (and creates then abandons that div node).

Hmm, let's think about this one.

comment:4 Changed 14 years ago by mumme

Owner: changed from mumme to bill

Bill, I don't think this ticket really "belongs" to me.

I'm not involved deeply enough in the development to make this call, Its not just ContentPane?'s, its every widget without Template.

comment:5 Changed 14 years ago by bill

Milestone: 1.02.0

comment:6 Changed 14 years ago by alex

why did this get punted? It's really really simple to fix.

comment:7 Changed 14 years ago by bill

Milestone: 2.01.0
Status: newassigned

comment:8 Changed 14 years ago by bill

Resolution: fixed
Status: assignedclosed

(In [11229]) Fixes #3211: automatically create node for widget if user hasn't supplied one.

Note: See TracTickets for help on using tickets.