Opened 7 years ago

Closed 6 years ago

Last modified 6 years ago

#15809 closed defect (fixed)

loader exception after parser removes first script node

Reported by: bill Owned by: Rawld Gill
Priority: undecided Milestone: 1.9
Component: Loader Version: 1.7.3
Keywords: Cc:
Blocked By: Blocking:

Description (last modified by bill)

On the line:

insertPoint.insertBefore(node, sibling);

Both chrome and FF get a NOT_FOUND_ERR: DOM exception 8. insertPoint is <body>, and sibling is

<script type="dojo/require">
	lang: "dojo/_base/lang",
	ItemFileReadStore: "dojo/data/ItemFileReadStore",
	BorderContainer: "dijit/layout/BorderContainer",
	ContentPane: "dijit/layout/ContentPane",
	Editor: "dijit/Editor"
</script>

Why do insertPoint and sibling have those weird values? Because the test tries to be clever by putting the <script src="dojo.js"> at the end of <body> rather than in <head>.

I'm still not sure why the test gets that error though, or whether it's a valid test, but please take a look.

Attachments (2)

editor.html (6.2 KB) - added by bill 7 years ago.
t15809.html (806 bytes) - added by Rawld Gill 6 years ago.
reduced example

Download all attachments as: .zip

Change History (8)

Changed 7 years ago by bill

Attachment: editor.html added

comment:1 Changed 7 years ago by bill

Description: modified (diff)

The issue could possibly be that the <script type="dojo/require"> gets deleted from the document at the same time that the loader is trying to inject new <script> tags into the document.

comment:2 Changed 6 years ago by csiknor

Had the same issue using the following code in a form:

<script type="dojo/on" data-dojo-event="submit" data-dojo-args="evt">
	console.log("Submit!");
	evt.preventDefault();

	require(["dojox/validate/web"], function(validate) {
		console.log("Hello");
	});
</script>

I was able the prevent the exception using a simple workaround: I've inserted an empty <script type="text/javascript"></script> element before the <script type="dojo/on"… element.

comment:3 Changed 6 years ago by Rawld Gill

Milestone: tbd1.9
Status: newassigned

comment:4 Changed 6 years ago by Rawld Gill

Summary: loader exception when dojo loaded in bodyloader exception after parser removes first script node

The problem is the loader insert algorithm inserts nodes relative to the first script node which, depending on the type of that script node, may be removed by the parser. The loader algorithm has proven quite stable and solves an IE problem.

Attaching reduced test case.

Changed 6 years ago by Rawld Gill

Attachment: t15809.html added

reduced example

comment:5 Changed 6 years ago by Rawld Gill

Resolution: fixed
Status: assignedclosed

In [30921]:

ignore script nodes with type=dojo... when determining script injection point; fixes #15809; !strict

comment:6 Changed 6 years ago by bill

#16992 is a duplicate of this ticket.

Note: See TracTickets for help on using tickets.