changeset 902:4b9f1de2c647

dlist add and delete both working in Iceape and Konqueror
author Adam Chlipala <adamc@hcoop.net>
date Thu, 06 Aug 2009 14:39:03 -0400
parents f17638dd3080
children 63114a2e5075
files lib/js/urweb.js
diffstat 1 files changed, 12 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/lib/js/urweb.js	Thu Aug 06 14:24:40 2009 -0400
+++ b/lib/js/urweb.js	Thu Aug 06 14:39:03 2009 -0400
@@ -269,13 +269,15 @@
   x.sources = null;
   x.closures = null;
 
-  var child = null;
+  var firstChild = null;
 
   x.recreate = function(v) {
     for (var ls = x.closures; ls; ls = ls.next)
       freeClosure(ls.data);
 
-    if (child) {
+    var next;
+    for (var child = firstChild; child && child != x; child = next) {
+      next = child.nextSibling;
       if (child.getElementsByTagName) {
         var arr = child.getElementsByTagName("script");
         for (var i = 0; i < arr.length; ++i) {
@@ -305,19 +307,22 @@
       var table = x.parentNode;
 
       var arr = dummy.getElementsByTagName("tbody");
+      firstChild = null;
       if (arr.length > 0) {
         var tbody = arr[0], next;
+        firstChild = document.createElement("script");
+        table.insertBefore(firstChild, x);
         for (var node = tbody.firstChild; node; node = next) {
           next = node.nextSibling;
-          table.appendChild(node);
+          table.insertBefore(node, x);
         }
       }
     } else {
-      child = document.createElement("span");
-      child.innerHTML = html;
-      runScripts(child);
+      firstChild = document.createElement("span");
+      firstChild.innerHTML = html;
+      runScripts(firstChild);
       if (x.parentNode)
-        x.parentNode.insertBefore(child, x);
+        x.parentNode.insertBefore(firstChild, x);
     }
   };