summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2012-07-22 09:42:17 -0400
committerGravatar Adam Chlipala <adam@chlipala.net>2012-07-22 09:42:17 -0400
commitf92a38c957b15bd5c4243d6aba527a1db8edc473 (patch)
tree310d0a64a16d536b951b44e288a27a1ea6033be6
parentedd64e5edc98649b741dad91ce8c6a902492a1c7 (diff)
Nicer <active> semantics
-rw-r--r--lib/js/urweb.js6
-rw-r--r--tests/activeFocus.ur18
2 files changed, 21 insertions, 3 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js
index 87adc0a3..1f003fc3 100644
--- a/lib/js/urweb.js
+++ b/lib/js/urweb.js
@@ -803,7 +803,6 @@ function dyn(pnode, s) {
var dummy = document.createElement("body");
dummy.innerHTML = "<table>" + html + "</table>";
- runScripts(dummy);
var table = x.parentNode;
if (table) {
@@ -831,12 +830,12 @@ function dyn(pnode, s) {
for (var node = tbody.firstChild; node; node = next) {
next = node.nextSibling;
table.insertBefore(node, x);
+ runScripts(node);
}
}
} else if (pnode == "tr") {
var dummy = document.createElement("body");
dummy.innerHTML = "<table><tr>" + html + "</tr></table>";
- runScripts(dummy);
var table = x.parentNode;
if (table) {
@@ -854,14 +853,15 @@ function dyn(pnode, s) {
for (var node = tr.firstChild; node; node = next) {
next = node.nextSibling;
table.insertBefore(node, x);
+ runScripts(node);
}
}
} else {
firstChild = document.createElement("span");
firstChild.innerHTML = html;
- runScripts(firstChild);
if (x.parentNode)
x.parentNode.insertBefore(firstChild, x);
+ runScripts(firstChild);
}
};
diff --git a/tests/activeFocus.ur b/tests/activeFocus.ur
new file mode 100644
index 00000000..94d465e9
--- /dev/null
+++ b/tests/activeFocus.ur
@@ -0,0 +1,18 @@
+fun main () : transaction page =
+ i <- fresh;
+ return <xml><body>
+ <ctextbox/>
+ <ctextbox id={i}/>
+ <active code={giveFocus i; return <xml>Done</xml>}/>
+ </body></xml>
+
+fun dynamic () : transaction page =
+ x <- source <xml/>;
+ return <xml><body>
+ <dyn signal={signal x}/>
+ <button onclick={fn _ => i <- fresh; set x <xml>
+ <ctextbox/>
+ <ctextbox id={i}/>
+ <active code={giveFocus i; return <xml>Done</xml>}/>
+ </xml>}/>
+ </body></xml>