This makes sense for IE (6/7?/8?), i dont if its needed for other browsers.On ie6 empty() method is used as seen inside the if(wrap):
this.empty().adopt(first.childNodes); On others it simply sets the innerHTML. Im not totally sure about the memory leaks on firefox and others but the core developers that made it are so... -- Fábio Miranda Costa Solucione Sistemas Front-End Engineer http://meiocodigo.com On Thu, Aug 6, 2009 at 9:12 AM, Tobi <[email protected]> wrote: > > To garbage collect elements and removing them properly... > Make this sense? > Maybe i mussunderstand empty(). > > On 6 Aug., 13:58, Fábio M. Costa <[email protected]> wrote: > > Why empty() it before setting html? > > > > -- > > Fábio Miranda Costa > > Solucione Sistemas > > Front-End Engineerhttp://meiocodigo.com > > > > > > > > On Thu, Aug 6, 2009 at 5:41 AM, Tobi <[email protected]> wrote: > > > > > Hello > > > > > Wouldn't It make sense to empty() the element first, before Set the > > > innerHTML? > > > Or better not empty for performance reasons? > > > > > This is the actual code from mootools 1.2.3 > > > > > var html = { > > > set: function(){ > > > this.empty(); // > > > <--------------------------------------------- ???????? > > > var html = Array.flatten(arguments).join(''); > > > var wrap = Browser.Engine.trident && > > > translations[this.get('tag')]; > > > if (wrap){ > > > var first = wrapper; > > > first.innerHTML = wrap[1] + html + > wrap[2]; > > > for (var i = wrap[0]; i--;) first = > > > first.firstChild; > > > this.empty().adopt(first.childNodes); > > > } else { > > > this.innerHTML = html; > > > } > > > } > > > }; >
