Loading ...
Sorry, an error occurred while loading the content.

YAHOO.util.DragDrop.swapNode() implementation for non-IE browsers

Expand Messages
  • datibbaw
    The swapNode() implementation in the DragDrop module is: this.swapNode = function(n1, n2) { if (n1.swapNode) { n1.swapNode(n2); } else { // the node reference
    Message 1 of 4 , Feb 17, 2006
    • 0 Attachment
      The swapNode() implementation in the DragDrop module is:

      this.swapNode = function(n1, n2) {
      if (n1.swapNode) {
      n1.swapNode(n2);
      } else {
      // the node reference order for the swap is a little tricky.
      var p = n2.parentNode;
      var s = n2.nextSibling;
      n1.parentNode.replaceChild(n2,n1);
      p.insertBefore(n1,s);
      }
      };

      This works fine unless n1 and n2 are siblings (for instance when
      there's no white-space between the two elements). The following patch
      worked for me, but it's not too pretty:

      add the following lines before the replaceChild() calls:

      if (s==n1) {
      s = p.insertBefore(document.createTextNode(''),n1)
      }

      This will separate the two siblings by adding an empty text node
      between the elements. I'd love to hear a better solution.


      Cheers,
      Jack
    • Miles
      I agree that this is a bug, and a fairly serious one. Your patch works for me also. Is there a place we should be reporting bugs besides this list? -miles
      Message 2 of 4 , Sep 1, 2006
      • 0 Attachment
        I agree that this is a bug, and a fairly serious one. Your patch
        works for me also.

        Is there a place we should be reporting bugs besides this list?

        -miles

        --- In ydn-javascript@yahoogroups.com, "datibbaw" <tjerk.meesters@...>
        wrote:
        >
        > The swapNode() implementation in the DragDrop module is:
        >
        > this.swapNode = function(n1, n2) {
        > if (n1.swapNode) {
        > n1.swapNode(n2);
        > } else {
        > // the node reference order for the swap is a little tricky.
        > var p = n2.parentNode;
        > var s = n2.nextSibling;
        > n1.parentNode.replaceChild(n2,n1);
        > p.insertBefore(n1,s);
        > }
        > };
        >
        > This works fine unless n1 and n2 are siblings (for instance when
        > there's no white-space between the two elements). The following patch
        > worked for me, but it's not too pretty:
        >
        > add the following lines before the replaceChild() calls:
        >
        > if (s==n1) {
        > s = p.insertBefore(document.createTextNode(''),n1)
        > }
        >
        > This will separate the two siblings by adding an empty text node
        > between the elements. I'd love to hear a better solution.
        >
        >
        > Cheers,
        > Jack
        >
      • Thomas S. Sha
        ... Yes. Please report the bug at: http://sourceforge.net/projects/yui/ as we use the SF tracker to monitor external reports. Regards, Thomas
        Message 3 of 4 , Sep 1, 2006
        • 0 Attachment
          --- In ydn-javascript@yahoogroups.com, "Miles" <mcrawfor@...> wrote:
          >
          >
          > I agree that this is a bug, and a fairly serious one. Your patch
          > works for me also.
          >
          > Is there a place we should be reporting bugs besides this list?
          >
          > -miles

          Yes. Please report the bug at: http://sourceforge.net/projects/yui/
          as we use the SF tracker to monitor external reports.

          Regards,
          Thomas
        • Miles
          ... I m entering it into the sourceforge bug tracker.
          Message 4 of 4 , Sep 1, 2006
          • 0 Attachment
            > Is there a place we should be reporting bugs besides this list?

            I'm entering it into the sourceforge bug tracker.
          Your message has been successfully submitted and would be delivered to recipients shortly.