[Dojo-checkins] [dojo] #10411: addOnWindowUnload broken on IE8, also breaking destroy process

dojo trac at dojotoolkit.org
Thu Nov 26 06:17:30 EST 2009


#10411: addOnWindowUnload broken on IE8, also breaking destroy process
----------------------+-----------------------------------------------------
 Reporter:  frietsch  |        Owner:  anonymous 
     Type:  defect    |       Status:  closed    
 Priority:  normal    |    Milestone:  tbd       
Component:  Dijit     |      Version:  1.3.2     
 Severity:  major     |   Resolution:  worksforme
 Keywords:            |  
----------------------+-----------------------------------------------------
Changes (by bill):

  * status:  new => closed
  * resolution:  => worksforme
  * component:  General => Dijit


Old description:

> 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.

New description:

 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.

--

Comment:

 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.

-- 
Ticket URL: <http://trac.dojotoolkit.org/ticket/10411#comment:1>
dojo <http://dojotoolkit.org/>
The Dojo UI Toolkit


More information about the Dojo-checkins mailing list