# HG changeset patch # User Adam Chlipala # Date 1231688498 18000 # Node ID d1cce194180d60f4d142791fbbb9a40c88d59f7b # Parent 889dc9fceb3a3108a507a2be72f155c0cbe9792e Do proper insertion of dynamic content within nested DOM containers diff -r 889dc9fceb3a -r d1cce194180d jslib/urweb.js --- a/jslib/urweb.js Sun Jan 11 10:22:19 2009 -0500 +++ b/jslib/urweb.js Sun Jan 11 10:41:38 2009 -0500 @@ -34,17 +34,26 @@ 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 -r 889dc9fceb3a -r d1cce194180d tests/ooo.ur --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/ooo.ur Sun Jan 11 10:41:38 2009 -0500 @@ -0,0 +1,8 @@ +fun main () : transaction page = + s <- source "Hi"; + return +
+ + Change it up! + +
diff -r 889dc9fceb3a -r d1cce194180d tests/ooo.urp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/ooo.urp Sun Jan 11 10:41:38 2009 -0500 @@ -0,0 +1,3 @@ +debug + +ooo