Opened 10 years ago

Closed 10 years ago

#10411 closed defect (worksforme)

addOnWindowUnload broken on IE8, also breaking destroy process

Reported by: frietsch Owned by: anonymous
Priority: high Milestone: tbd
Component: Dijit Version: 1.3.2
Keywords: Cc:
Blocked By: Blocking:

Description (last modified by bill)

I was checking for memory leaks and noticed my uninitialize methods weren't called at all, even in IE. It turns out that the code below (dijit manager) does nothing:

if(dojo.isIE){
	// Only run this for IE because we think it's only necessary in that case,
	// and because it causes problems on FF.  See bug #3531 for details.
	dojo.addOnWindowUnload(function(){
		dojo.forEach(dijit.findWidgets(dojo.body()), function(widget){
			if(widget.destroyRecursive){
				widget.destroyRecursive();
			}else if(widget.destroy){
				widget.destroy();
			}
		});
	});
}

If I change "addOnWindowUnload", to "addOnUnload", uninitialize gets called. However, I fear this is too late to clean up the DOM, as it might be screwed up in onUnload already (read something like that somewhere in the Dojo docs). Any ideas? Maybe this bug is already addressed in 1.4, sorry if so, currently have no time to check for.

Change History (1)

comment:1 Changed 10 years ago by bill

Component: GeneralDijit
Description: modified (diff)
Resolution: worksforme
Status: newclosed

Actually, that code is getting called (even in 1.3).

Probably you are testing with an alert() or something similar, but by the time the code runs, it's too late to display the alert. However, if you add a "debugger;" into that code you can see it running when the page unloads. (Of course, don't forget to press the "start debugging" button in IE8, from the developer's console.)

addOnLoad() is not appropriate because it sometimes gets called even when the page isn't unloading, and (of course) it would be bad to destroy the widgets in that case.

Note: See TracTickets for help on using tickets.