Hi Rob,

> I don't think there's any need to remove then insert, you can just
> insert the node in the new location.

Thanks!  You're right (of course!), it's right there in the spec from
day 1:

> and the function becomes:
>   function moveDown(el) {
>     var next = $(el).next();
>     el.parentNode.insertBefore(el, next.nextSibling);
>   }

What is it's already the bottom element?  'next' will be undefined, so
'next.nextSibling' will raise an error.  That's what the branch is
there to handle.

Handling that and allowing for text nodes we want to ignore:

    function moveDown(el)
        var next;

        el = $(el);
        next = el.next();
        if (next)
            el.parentNode.insertBefore(el, next.next());

Still an improvement over my original, in that there's no need for us
to go through Prototype's Element.insert() when we can just use the
DOM's insertBefore -- not that this is likely to be in some massive
loop. :-)

T.J. Crowder
tj / crowder software / com

You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 

Reply via email to