Login Register

mishap handling subscribe to dijit.Tree which then causes IE to hang instead of firing onclick event created with connect

I somehow stubled upon a great way to hang IE and max out the cpu of your machine. A year later, I've finally figured out how to make it go away, so I thought I would share. I'm still using a version 1 of dojo that I downloaded on 3/10/2008 and I don't have time to deal with any new issues that might arise from upgrading to the latest version, so hopefully someone can test this on the latest.

I've left a lot of it out, but basically I have an object which I create using syntax as I've written at the end of this posting.

For the longest time I've had this bug that displaying the tree, and expanding nodes works fine and leaves no problems. But, clicking on a node leaves something in a state that would cause other code to crash later on. That 'other code' involved a slew of event handlers that I created using dojo.connect. The bizarre thing was that most of the event handlers worked fine, but for some reason, trying to fire the 'onclick' event would freeze IE and max the cpu out indefinitely until I forced IE to shutdown.

Apparently, if I change it to where in declaring this object I initially set this.returnValue and this.returnLabel = "" instead of null, the problem goes away completely.

Something about that treehandler function that gets fired when the tree publishes an 'execute' message, assigns

this.returnLabel = nodeWidget.item.label;
this.returnValue  = nodeWidget.item.idApp;

when this.returnLabel and this.returnValue were null hoses something.

var PopupTree = function(_baseDomNode){
 this.returnValue = null;
 this.returnLabel = null;
 this.baseDomNodeId = _baseDomNode;
 PopupTree.prototype.build = function(_storeObject){     
            try
            {
                var newdiv = document.createElement('div');
                var rootnode = dojo.byId(this.baseDomNodeId);
                newdiv.id = "treebase";
                rootnode.appendChild(newdiv);
                
                this.dojoObject =new dijit.Tree({
                            id: "wtreebase",
                            store: _storeObject,
                            query: {type:'l0'},
                            labelAttr: "label",
                            typeAttr: "type"},dojo.byId("treebase"));  
               
            }
            this.aTopics.push(dojo.subscribe("wtreebase",this, this.treeHandler)); 
      };        
 
PopupTree.prototype.treeHandler = function(message){
    try{
       if (message.event != 'execute') {
            return;
       }
       var nodeWidget = message.node;
       if (nodeWidget == null) {
             return;
       }
       this.returnLabel = nodeWidget.item.label;
       this.returnValue  = nodeWidget.item.idApp;
   }
   catch(e)
   {alert('problem');}
 };
};

Ok, its not fixed after all

Oh, well, it was fixed yesterday. Somehow its broken again today. Back to the drawing board on this one.