changeset 903:63114a2e5075

<dyn> inside <tr>
author Adam Chlipala <adamc@hcoop.net>
date Thu, 06 Aug 2009 14:57:44 -0400
parents 4b9f1de2c647
children 6d9538ce94d8
files lib/js/urweb.js src/monoize.sml tests/dcol.ur tests/dcol.urp tests/dcol.urs
diffstat 5 files changed, 37 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/lib/js/urweb.js	Thu Aug 06 14:39:03 2009 -0400
+++ b/lib/js/urweb.js	Thu Aug 06 14:57:44 2009 -0400
@@ -302,8 +302,6 @@
       var dummy = document.createElement("body");
       dummy.innerHTML = "<table>" + html + "</table>";
       runScripts(dummy);
-      var rows = dummy.firstChild.rows;
-      var nRows = rows.length;
       var table = x.parentNode;
 
       var arr = dummy.getElementsByTagName("tbody");
@@ -317,6 +315,23 @@
           table.insertBefore(node, x);
         }
       }
+    } else if (pnode == "tr") {
+      var dummy = document.createElement("body");
+      dummy.innerHTML = "<table><tr>" + html + "</tr></table>";
+      runScripts(dummy);
+      var table = x.parentNode;
+
+      var arr = dummy.getElementsByTagName("tr");
+      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.insertBefore(node, x);
+        }
+      }
     } else {
       firstChild = document.createElement("span");
       firstChild.innerHTML = html;
--- a/src/monoize.sml	Thu Aug 06 14:39:03 2009 -0400
+++ b/src/monoize.sml	Thu Aug 06 14:57:44 2009 -0400
@@ -2645,13 +2645,15 @@
 
                   | "dyn" =>
                     let
-                        val inTable = case targs of
-                                          (L.CRecord (_, ctx), _) :: _ =>
-                                          List.exists (fn ((L.CName "Table", _), _) => true
-                                                        | _ => false) ctx
-                                        | _ => false
+                        fun inTag tag = case targs of
+                                            (L.CRecord (_, ctx), _) :: _ =>
+                                            List.exists (fn ((L.CName tag', _), _) => tag' = tag
+                                                          | _ => false) ctx
+                                          | _ => false
                                                
-                        val tag = if inTable then
+                        val tag = if inTag "Tr" then
+                                      "tr"
+                                  else if inTag "Table" then
                                       "table"
                                   else
                                       "span"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/dcol.ur	Thu Aug 06 14:57:44 2009 -0400
@@ -0,0 +1,8 @@
+fun main () =
+  s <- source <xml><td>A</td><td>A'</td></xml>;
+  return <xml><body>
+    <button value="Click me!" onclick={set s <xml><td>B</td><td>B'</td></xml>}/><br/>
+    <table><tr><td>Pre</td><td>Pre'</td></tr>
+      <tr><td>Hehe</td><dyn signal={signal s}/><td>Hoho</td></tr>
+      <tr><td>Post</td><td>Post</td><td>Post'</td></tr></table>
+  </body></xml>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/dcol.urp	Thu Aug 06 14:57:44 2009 -0400
@@ -0,0 +1,3 @@
+debug
+
+dcol
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/dcol.urs	Thu Aug 06 14:57:44 2009 -0400
@@ -0,0 +1,1 @@
+val main : unit -> transaction page