palimadra / iui

Automatically exported from code.google.com/p/iui
MIT License
0 stars 0 forks source link

target="_replace" doesn't work as expected when there are two (or more) such links #14

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
On a page with content that looks similar to this:

<ul>
  <li><a href="page1" target="_replace">First Page</a></li>
  <li><a href="page2" target="_replace">Second Page</a></li>
</ul>

Clicking on the "First Page" will get the contents of page1 but the content
is placed _after_ <li><a href="page2" target="_replace">Second Page</a></li>.

The contents should be placed before the "Second Page" link.

I tried this patch and it worked fine for my case.

diff -Nrub /Users/dous/Desktop/iui/iui.js /Users/dous/Desktop/iui/iui.js.new
--- /Users/dous/Desktop/iui/iui.js  2007-07-16 14:03:04.000000000 +0800
+++ /Users/dous/Desktop/iui/iui.js.new  2007-08-31 04:10:04.000000000 +0800
@@ -366,10 +366,10 @@
     var frag = document.createElement(parent.localName);
     frag.innerHTML = source;

-    page.removeChild(parent);
-
     while (frag.firstChild)
-        page.appendChild(frag.firstChild);
+        page.insertBefore(frag.firstChild, parent);
+
+    page.removeChild(parent);
 }

 function $(id) { return document.getElementById(id); }

Original issue reported on code.google.com by adpenara...@gmail.com on 30 Aug 2007 at 8:10

GoogleCodeExporter commented 9 years ago
That works for me, too.  Thanks for the patch!

Original comment by danieldickison@gmail.com on 8 Sep 2007 at 5:03

GoogleCodeExporter commented 9 years ago
Nice one, works.
This is really a bug if you go by the documentation on the blog.

Original comment by jee...@gmail.com on 21 Jan 2009 at 6:04