Opened 13 years ago

Closed 13 years ago

#1991 closed defect (wontfix)

Adding <base> tag causes DOJO loading to fail...

Reported by: erictankok@… Owned by: liucougar
Priority: blocker Milestone: 0.9
Component: General Version: 0.4
Keywords: Cc:
Blocked By: Blocking:

Description

Hi,

I am using IE 6 SP2 on Windows XP SP2 with DOJO 0.4 Widgets edition.

When the page contains a <base> tag, DOJO will fail to load.

The IE Runtime Error popup is:

Line: 2295
Error: 'childNodes' is null or not an object

I traced deeper with MS Script Editior and found that dojo.body() was returning "undefined" which caused the failure.

-Eric erictankok@…


Test HTML page:

<html>
<head>
<title>DOJO Error</title>
<base href="http://www.myserver.com/my/html/myDojoError.html"/>

<script type="text/javascript" 
        src="/my/js/dojo.js.uncompressed.js"></script>

</head>
<body>
</body>
</html>

CALL TRACE: ===========

if(dojo.render.html.ie && dojo.render.os.win){
	document.attachEvent("onreadystatechange", function(e){
		if(document.readyState == "complete"){
======>>		dj_load_init();
		}
	});
}

function dj_load_init(e){
...
	var initFunc = function(){
		//perform initialization
		if(dojo.render.html.ie){
======>>		dojo.hostenv.makeWidgets();
		}
	};

	if(dojo.hostenv.inFlightCount == 0){
======>>	initFunc();
		dojo.hostenv.modulesLoaded();
	}else{
		dojo.addOnLoad(initFunc);
	}
}

dojo.doc = function(){
	// summary:
	//	return the document object associated with the dojo.global()
	return dj_currentDocument;
}

dojo.body = function(){
	// summary:
	//	return the body object associated with dojo.doc()
	// Note: document.body is not defined for a strict xhtml document
	return dojo.doc().body || dojo.doc().getElementsByTagName("body")[0];
}

dojo.hostenv.makeWidgets = function(){
...
	if((djConfig.parseWidgets)||(sids.length > 0)){
		if(dojo.evalObjPath("dojo.widget.Parse")){
			// we must do this on a delay to avoid:
			//	http://www.shaftek.org/blog/archives/000212.html
			// (IE bug)
			var parser = new dojo.xml.Parse();
			if(sids.length > 0){
				for(var x=0; x<sids.length; x++){
					var tmpNode = 	document.getElementById(sids[x]);
					if(!tmpNode){ continue; }
					var frag = parser.parseElement(tmpNode, null, true);
					dojo.widget.getParser().createComponents(frag);
				}
				}else if(djConfig.parseWidgets){
====>>					var frag  = parser.parseElement(dojo.body(), null, true);
					dojo.widget.getParser().createComponents(frag);
				}
		}
	}
...
}


this.parseElement = function(node, hasParentNodeSet, optimizeForDojoML, thisIdx){
...
====>>	for(var i = 0; i < node.childNodes.length; i++){...}
...
}

Change History (12)

comment:1 Changed 13 years ago by bill

Component: WidgetsGeneral
Owner: changed from bill to liucougar

Cougar, this apparently deals w/dojo.body(). Want to take a look?

See also #2019.

comment:2 Changed 13 years ago by liucougar

change this: <base href="http://www.myserver.com/my/html/myDojoError.html"/>

to <base href="http://www.myserver.com/my/html/myDojoError.html"></base>

does that work for you?

comment:3 Changed 13 years ago by erictankok@…

Thanks liucougar.

Using the full form of <base></base> works.

I was also previously using Struts <html:base> tag which generates the shorthand <base/> tag.

Just wondering, why did the shorthand <base/> tag cause this issue with Dojo on IE? Firefox 2 works fine.

That brings me to the question of whether using shorthand forms of html tags will cause the same issue.

comment:4 Changed 13 years ago by guest

is this fix going to find its way into milestone 4.1?

it is a blocker in IE6. dojo is not usable with this bug.

comment:5 Changed 13 years ago by liucougar

Milestone: 0.4.1
Resolution: invalid
Status: newclosed

that's an IE bug

comment:6 Changed 13 years ago by guest

Resolution: invalid
Status: closedreopened

I don´t think this is an IE bug. The same code works with dojo 3.1 in IE. As bill already mentioned before, I also think it has to do with dojo.body()

comment:7 Changed 13 years ago by liucougar

what if you replace that dojo.body() with document.body? does that work for you in IE?

comment:8 Changed 13 years ago by liucougar

Milestone: 0.4.10.5

I tried the test page with unbuilt dojo (dojo trunk checkout), nothing wrong at all (IE6, XP sp2)

could you confirm whether you have this issue with dojo trunk/0.4 branch? and please also check whether a built trunk/0.4 branch works for you.

punt to 0.5 in any case

comment:9 Changed 13 years ago by guest

I replaced dojo.body() with document.body. This didn´t help.

I tried dojo from trunk and also the latest build version of dojo 0.4! Both doesn´t work if there´s a <base/> tag in the header which was created by struts.

Any ideas?

comment:10 Changed 13 years ago by liucougar

no clue, maybe your version of IE?

mine is with latest patch applied

comment:12 Changed 13 years ago by Tom Trenka

Resolution: wontfix
Status: reopenedclosed

This is an IE "bug" and a duplicate of ticket #557. The main issue is making a choice between enabling VML support out of the box, or attempting to support a malformed BASE tag, and we chose VML support.

As far as we can tell, a big part of the issue is that the BASE tag was never designed to be a singleton tag at all (like IMG or BR); in many ways it was designed to operate like SCRIPT, where you need to explicitly close the tag. While the Moz team added code to allow the correct interpretation of the singleton, the IE team did not.

Closing this bug as "wontfix".

Note: See TracTickets for help on using tickets.