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; > > } > > } > > };
