Ticket #5950: dojoParserStartup.patch

File dojoParserStartup.patch, 1.6 kB (added by guest, 10 months ago)

Add to instantiate method of dojo.parser a second optional parameter that if is present and is false don't startup instances. Needed for delayed startup. Provided by Alessandro Ferrari

  • parser.js

     
    119119                return new Function(preamble+script.innerHTML+suffix); 
    120120        } 
    121121 
    122         this.instantiate = function(/* Array */nodes){ 
     122        this.instantiate = function(/* Array */nodes, /* boolean */doStartup){ 
    123123                // summary: 
    124124                //              Takes array of nodes, and turns them into class instances and 
    125125                //              potentially calls a layout method to allow them to connect with 
    126                 //              any children             
     126                //              any children 
     127                //              If optional second parameter is false don't startup instances 
    127128                var thelist = []; 
    128129                d.forEach(nodes, function(node){ 
    129130                        if(!node){ return; } 
     
    204205                        } 
    205206                }); 
    206207 
    207                 // Call startup on each top level instance if it makes sense (as for 
    208                 // widgets).  Parent widgets will recursively call startup on their 
    209                 // (non-top level) children 
    210                 d.forEach(thelist, function(instance){ 
    211                         if(     instance  &&  
    212                                 instance.startup && 
    213                                 !instance._started &&  
    214                                 (!instance.getParent || !instance.getParent()) 
    215                         ){ 
    216                                 instance.startup(); 
    217                         } 
    218                 }); 
     208                if(doStartup||arguments.length==1){ 
     209                        // Call startup on each top level instance if it makes sense (as for 
     210                        // widgets).  Parent widgets will recursively call startup on their 
     211                        // (non-top level) children 
     212                        d.forEach(thelist, function(instance){ 
     213                                if(     instance  &&  
     214                                        instance.startup && 
     215                                        !instance._started &&  
     216                                        (!instance.getParent || !instance.getParent()) 
     217                                ){ 
     218                                        instance.startup(); 
     219                                } 
     220                        }); 
     221                } 
    219222                return thelist; 
    220223        }; 
    221224