From d71a90ca23170fd7fef9ad0f9ccf6afc01d3f372 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sun, 11 Jan 2009 10:41:38 -0500 Subject: Do proper insertion of dynamic content within nested DOM containers --- jslib/urweb.js | 13 +++++++++++-- tests/ooo.ur | 8 ++++++++ tests/ooo.urp | 3 +++ 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 tests/ooo.ur create mode 100644 tests/ooo.urp 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 +
+ + Change it up! + +
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 -- cgit v1.2.3