Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#4631 closed defect (invalid)

dijit._Templated generates "Internet Explorer cannot open the Internet site" error

Reported by: guest Owned by: anonymous
Priority: high Milestone:
Component: Dijit Version: 0.9
Keywords: Cc: [email protected]
Blocked By: Blocking:


The dojo.body().appendChild(tn) statement found in the dijit._Templated._createNodesFromText function appears to generate an "Internet Explorer cannot open the Internet site" error for IE 6 & 7. When I remove this line, the error goes away, but nothing is rendered.

The following snippet shows a very simple example of the problem.

<script type="text/javascript"> var djConfig = {

"isDebug": true

}; </script>
<script type="text/javascript" src="dojo-0.9.0/dojo/dojo.js.uncompressed.js"></script>
<script type="text/javascript" src="dojo-0.9.0/dijit/dijit.js.uncompressed.js"></script>
<script type="text/javascript">

dojo.require("dijit._Widget"); dojo.require("dijit._Templated");

dojo.declare("Button", [dijit._Widget, dijit._Templated], {

templateString: "<input type="submit" dojoAttachPoint="domNode"/>",
postCreate: function() {

this.domNode =;
this.domNode.value = this.value;



<form id="form1">
<span id="form1:button1"/>
<script type="text/javascript">

var domNode = document.getElementById("form1:button1");
var widget = new Button({

"id": "form1:button1", "value": "Click Me"

}, domNode);


Attachments (2)

index.html (953 bytes) - added by guest 14 years ago.
Custom widget example
4631.html (929 bytes) - added by bill 14 years ago.
working example

Download all attachments as: .zip

Change History (10)

Changed 14 years ago by guest

Attachment: index.html added

Custom widget example

comment:1 Changed 14 years ago by bill

Component: GeneralDijit
Resolution: invalid
Status: newclosed

I'm guessing the problem has something to do with that strange line

this.domNode =

domNode needs to be a dom node, not a string.

Changed 14 years ago by bill

Attachment: 4631.html added

working example

comment:2 Changed 14 years ago by guest

Resolution: invalid
Status: closedreopened

Sorry, I made a cut/paste mistake in the example. Simply change:

this.domNode =

to: =

And you will see the error.

Regardless, my point is that the widget code does not work unless it is assigned to the window.onload event. I believe there is still an underlying issue with calling appendChild() from dijit._Templated._createNodesFromText. The dynamic approach (used in the example) worked in Dojo .4, but this one line breaks IE. We've built a library of 30+ custom components on top of that behavior.

comment:3 Changed 14 years ago by bill

Resolution: invalid
Status: reopenedclosed

Yes, it's a requirement that all startup-related widget code, and dojo code in general, be called from dojo.addOnLoad(). I attached a working example. See 4631.html.

comment:4 Changed 14 years ago by guest

Resolution: invalid
Status: closedreopened

Not only are you forcing widget developers to change code, but existing web apps must modify their code as well. For example, a web app developer cannot obtain the newly created button element using:

var button = document.getElementById("form1:button1");

That is, unless they also move their code to the window.onLoad event. And even if they do that, we cannot guarantee that widgets will be created before their code is invoked.

Regardless, forcing developers to change existing apps is not acceptable. All because of one line of code in Dojo .9?

comment:5 Changed 14 years ago by bill

Resolution: invalid
Status: reopenedclosed

I'm sorry you don't like the way dojo works, but stop reopening this bug.

comment:6 Changed 14 years ago by guest

Would you at least consider providing some control over how the temporary div tag is added? Could the div tag be added when _Templated.js is included in the page? Again, it's the dojo.body().appendChild(tn) call that's killing us.

comment:7 Changed 14 years ago by guest

Looking at the dojo.html.createNodesFromText function from Dojo .4, I see that it is also calling dojo.body().appendChild(tn); however, IE does not throw an error in this version. The difference appears to be that the temporary div tag is removed at the end of the function.

dojo.html.createNodesFromText = function (txt, trim) { ...

dojo.html.destroyNode(tn); return nodes;


That said, I created a simple experiment below. As long as the div tag is removed, IE will not generate an error.

<form id="form1">
<script type="text/javascript">

var div = document.createElement("div");
var body = document.getElementsByTagName("body")[0];
div.innerHTML = "This is a test";


comment:8 Changed 14 years ago by bill

Sorry, I can see you are really into this but I think modifying <body> programatically as <body> is being downloaded is dangerous, depending on the browser/browser version and also the doctype (strict vs. not) of the document. Anyway, creating widgets before the DOMContentLoaded event is not something I'm interested in testing or supporting at this point. Maybe in the future. Also note that when using dojo from an edge server, those dojo.require() calls are asynchronous, so at the time you hit that embedded script tag, the widget javascript code may not even have finished downloading yet.

Note: See TracTickets for help on using tickets.