Opened 8 years ago
Closed 8 years ago
#16958 closed defect (fixed)
Loader Exception in dojo-inject-api when insertPoint is removed
Reported by: | chris2m | Owned by: | Rawld Gill |
---|---|---|---|
Priority: | blocker | Milestone: | 1.9 |
Component: | Loader | Version: | 1.8.3 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
This ticket is related to http://bugs.dojotoolkit.org/changeset/30921/dojo%20bugs.dojotoolkit.org/ticket/15809
When injecting scripts into the dom dojo determines an insertPoint and a sibling node. The insertPoint typically is the head tag and the sibling is usually the first script node in the document. Under some circumstances the sibling node might be a temporarily inserted script tag (e.g. tracker code) which is removed at some point. Dojo currently relies on the sibling node being always present.
In case the sibling node is removed, all subsequent require("module") calls fail. The Patch used in #15809 is a workaround for the specific error situation described in that ticket, but does not provide a generic solution to the removal of the sibling nodes.
To fix this issue in my code I have inserted the following lines that check if the sibling is still present in the DOM. If not, insertPoint and sibling are re-assigned.
node.type = "text/javascript"; node.charset = "utf-8"; node.src = url; // PATCH START if (!((insertPoint.contains && insertPoint.contains(sibling)) || sibling.sourceIndex>=0)) { sibling = doc.getElementsByTagName("script")[0]; insertPoint= sibling.parentNode; } // PATCH END insertPoint.insertBefore(node, sibling);
Best, Chris
Change History (5)
comment:1 Changed 8 years ago by
Component: | General → Loader |
---|---|
Owner: | set to Rawld Gill |
comment:2 Changed 8 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:3 Changed 8 years ago by
Milestone: | tbd → 1.9 |
---|---|
Priority: | undecided → low |
I changed the algorithm to prefer the node sniffed as the last node that has either a data-dojo-config or djConfig attribute, or, failing that sniff, the last node sniffed with its src attribute containing "dojo.js".
In order for this to work, the sniff API must be turned on (it is by default).
This means that if you remove the sniffed node, you're still going to have a problem. In such cases, you could solve the problem by adding teh following node after any nodes that are going to be removed.
<script data-dojo-config=""></script>
and never removing it.
In 2.0, we'll just dispense with this whole insert point idea and insert into head...it's all to solve an ancient IE problem that probably no longer important.
comment:4 Changed 8 years ago by
Priority: | low → blocker |
---|---|
Resolution: | fixed |
Status: | closed → reopened |
[31271] breaks dijit/tests/registry.html (and probably other things) on IE8. It gets an exception loading the page.
In [31271]: