Ticket #5005 (new defect)
can't insert templated widget's DOM tree into an iframe
| Reported by: | byersa@… | Owned by: | bill |
|---|---|---|---|
| Priority: | normal | Milestone: | future |
| Component: | Dijit | Version: | 0.9 |
| Severity: | normal | Keywords: | |
| Cc: |
Description (last modified by bill) (diff)
I am posting a bug that I first put on the forum list. It is about a half-dozen lines so I am going to describe the code rather than supply it because I don't have an CLA in place.
I have a situation in which I am trying to dynamically change the content of an iframe with code like:
var refNode = dojo.doc.createElement("div");
var newWidget = new cls({...}, refNode);
ifr.contentWindow.document.body.appendChild(newWidget.domNode);
This works in FF, but not IE. It complains about an "invalid argument". I finally figured out it was because the element that I am appending was not created by the iframe's document. I thought an answer to this would be to create refNode like this:
var refNode = iframe_contentwindow.document.createElement("div");
var newWidget = new cls({...}, refNode);
But in poking around in _Templated, I find that it uses "dojo.doc" to create the element it returns. I changed the code for it to see if it has a "this.srcNodeRef" and uses it's ownerDocument to create an element and that seems to work. I had to add "srcNodeRef" to _Templated and move the "tn" var inside the function so it gets recreated each time.
So the changes I made were:
1. Add srcNodeRef ivar to _Templated.
2. In dijit._Templated._createNodesFromText, I move the def of "tn" inside the function as it would never allow a change if the "tn" var persists.
3. In dijit._Templated._createNodesFromText, I did a test on whether or not this.srcNodeRef exists and, if it does, set tn by creating a "div" from the this.srcnodeRef ownerDocument. There is also a line right below it that also uses "dojo.doc.createElement. I moved that line inside the conditional clauses, as well.
If you want my code, I will be glad to fill out a CLA.
Al Byers byersa@… 801-400-5111