summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Saulo Araujo <saulo2@gmail.com>2016-07-16 14:06:00 -0300
committerGravatar Saulo Araujo <saulo2@gmail.com>2016-07-16 14:06:00 -0300
commitfb5324f8180b089c75f12d165869909db941878f (patch)
tree1b5c79fb689aded584fd06b8a7449e1f25c072e4
parent885358adcc03e0b4b2599c3d1072c0ac169ed894 (diff)
Fix for "normalizeTable" nesting thead and tfoot in tbody
-rw-r--r--lib/js/urweb.js10
-rw-r--r--tests/normalizeTable.ur50
-rw-r--r--tests/normalizeTable.urp1
-rw-r--r--tests/normalizeTable.urs1
4 files changed, 58 insertions, 4 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js
index 1f44a97b..68e7979d 100644
--- a/lib/js/urweb.js
+++ b/lib/js/urweb.js
@@ -879,10 +879,12 @@ function normalizeTable(table) {
for (script = table.firstChild; script && script != tbody; script = next) {
next = script.nextSibling;
- if (firstChild)
- tbody.insertBefore(script, firstChild);
- else
- tbody.appendChild(script);
+ if (script.tagName === "SCRIPT") {
+ if (firstChild)
+ tbody.insertBefore(script, firstChild);
+ else
+ tbody.appendChild(script);
+ }
}
return;
diff --git a/tests/normalizeTable.ur b/tests/normalizeTable.ur
new file mode 100644
index 00000000..be16d935
--- /dev/null
+++ b/tests/normalizeTable.ur
@@ -0,0 +1,50 @@
+fun main () =
+visible <- source True;
+return
+ <xml>
+ <body>
+ <section>
+ <h1>Static table</h1>
+ <table border=1>
+ <thead>
+ <tr>
+ <th>Column 0</th>
+ <th>Column 1</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>A</td>
+ <td>B</td>
+ </tr>
+ </tbody>
+ </table>
+ </section>
+
+ <section>
+ <h1>Dynamic table</h1>
+ <table border=1>
+ <thead>
+ <tr>
+ <th>Column 0</th>
+ <th>Column 1</th>
+ </tr>
+ </thead>
+ <tbody>
+ <dyn signal={
+ visible <- signal visible;
+ return (if visible then
+ <xml>
+ <tr>
+ <td>A</td>
+ <td>B</td>
+ </tr>
+ </xml>
+ else
+ <xml></xml>)
+ }/>
+ </tbody>
+ </table>
+ </section>
+ </body>
+ </xml>
diff --git a/tests/normalizeTable.urp b/tests/normalizeTable.urp
new file mode 100644
index 00000000..e22cda3b
--- /dev/null
+++ b/tests/normalizeTable.urp
@@ -0,0 +1 @@
+normalizeTable
diff --git a/tests/normalizeTable.urs b/tests/normalizeTable.urs
new file mode 100644
index 00000000..9e80cf40
--- /dev/null
+++ b/tests/normalizeTable.urs
@@ -0,0 +1 @@
+val main: unit -> transaction page