Core Team & Contributors,

Regardless of the decision regarding DOM builder, I would like to
propose adding the following node-insertion methods to the Element
object.  These methods are basically the same as discussed several weeks
ago
(http://www.mail-archive.com/prototype-core@googlegroups.com/msg00057.html)
but avoid name conflict and reliance on Abstract.Insertion.

insertAfter (complement of insertBefore)
prependChild (complement of appendChild)
addNodeBefore
addNodeAfter

Source + Test - http://pastie.caboo.se/48121

Best regards,

Ken Snyder



// for those who prefer in-mail code
Element.addMethods({

  insertAfter: function(parent, node, refNode) {
    parent = $(parent);
    // refNode must be a node, not an id
    var nextSibling = refNode.next();
    if( nextSibling ) {
      parent.insertBefore(node, nextSibling);
    } else {
      parent.appendChild(node);
    }
    // not chainable in order to mimmick behavior of insertBefore()
  },

  addNodeBefore: function(element, node) {
    element = $(element);
    element.parentNode.insertBefore(node, element);
    return element;
  },

  addNodeAfter: function(element, node) {
    element = $(element);
    $(element.parentNode).insertAfter(node, element);
    return element;
  },

  prependChild: function(element, node) {
    element = $(element);
    var refNode = element;
    if( refNode = element.down() ) {
      element.insertBefore(node, refNode);
    } else {
      element.appendChild(node);
    }
    // not chainable in order to mimmick behavior of appendChild()
  }
});



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to