of course, you're right

On May 24, 10:51 pm, Michael Russell <[email protected]> wrote:
> you really don't need a fragment for that.
>
> this:
>
> var elements = $$('span');
> elements.each(function(elm){
>     var fragment = document.createDocumentFragment();
>     fragment.appendChild(document.createTextNode('X'));
>     elm.parentNode.insertBefore(fragment, elm.nextSibling);
>
> });
>
> could just be:
>
> var elements = $$('span');
> elements.each(function(elm){
>     var txtNode = document.createTextNode('X')
>     elm.parentNode.insertBefore(txtNode, elm.nextSibling);
>
> });
>
> Fragments are really nice when you don't want to inject a wrapper element
> but want to insert n+1 nodes into the DOM. Using it will cause the browser
> to only re[paint/structure] the DOM once when injecting them instead of on
> each iteration of your elements array

Reply via email to