summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-01-11 10:41:38 -0500
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-01-11 10:41:38 -0500
commit0d9b4b2f411af95f9a886a3b188f0b2c688be27b (patch)
tree78e67b40776c15813d38f98e1ca793a30a4a4792
parent0c5be5455c4f1e078831cb434bb9df215a410ad9 (diff)
Do proper insertion of dynamic content within nested DOM containers
-rw-r--r--jslib/urweb.js13
-rw-r--r--tests/ooo.ur8
-rw-r--r--tests/ooo.urp3
3 files changed, 22 insertions, 2 deletions
diff --git a/jslib/urweb.js b/jslib/urweb.js
index 0f9c06cf..8e39f9f3 100644
--- a/jslib/urweb.js
+++ b/jslib/urweb.js
@@ -34,17 +34,26 @@ function sb(x,y) {
return s;
}
+function myParent() {
+ var pos = document;
+
+ while (pos.lastChild && pos.lastChild.nodeType == 1)
+ pos = pos.lastChild;
+
+ return pos.parentNode;
+}
+
function dyn(s) {
var x = document.createElement("span");
x.innerHTML = s.v;
- document.body.appendChild(x);
+ myParent().appendChild(x);
s.h = cons(function() { x.innerHTML = s.v }, s.h);
}
function inp(t, s) {
var x = document.createElement(t);
x.value = s.v;
- document.body.appendChild(x);
+ myParent().appendChild(x);
s.h = cons(function() { x.value = s.v }, s.h);
x.onkeyup = function() { sv(s, x.value) };
}
diff --git a/tests/ooo.ur b/tests/ooo.ur
new file mode 100644
index 00000000..5401fa70
--- /dev/null
+++ b/tests/ooo.ur
@@ -0,0 +1,8 @@
+fun main () : transaction page =
+ s <- source "Hi";
+ return <xml><body>
+ <form>
+ <textbox{#A} source={s}/>
+ Change it up!
+ </form>
+ </body></xml>
diff --git a/tests/ooo.urp b/tests/ooo.urp
new file mode 100644
index 00000000..5a510107
--- /dev/null
+++ b/tests/ooo.urp
@@ -0,0 +1,3 @@
+debug
+
+ooo