summaryrefslogtreecommitdiff
path: root/jslib/urweb.js
diff options
context:
space:
mode:
Diffstat (limited to 'jslib/urweb.js')
-rw-r--r--jslib/urweb.js36
1 files changed, 30 insertions, 6 deletions
diff --git a/jslib/urweb.js b/jslib/urweb.js
index 86c3808c..508f4318 100644
--- a/jslib/urweb.js
+++ b/jslib/urweb.js
@@ -1,18 +1,42 @@
+function cons(v, ls) {
+ return { n : ls, v : v };
+}
function callAll(ls) {
for (; ls; ls = ls.next)
ls.v();
}
-function sc(v) { return {v : v, h : null} }
-function sv(s, v) { s.v = v; callAll(s.h); }
+function sc(v) {
+ return {v : v, h : null};
+}
+function sv(s, v) {
+ s.v = v;
+ callAll(s.h);
+}
-function ss(s) { return s }
-function sr(v) { return {v : v, h : null} }
-function sb(x,y) { return {v : y(x.v).v, h : null} }
+function ss(s) {
+ return s;
+}
+function sr(v) {
+ return {v : v, h : null};
+}
+function sb(x,y) {
+ var z = y(x.v);
+ var s = {v : z.v, h : null};
+
+ function reZ() {
+ z.h = cons(function() { s.v = z.v; callAll(s.h); }, z.h);
+ }
+
+ x.h = cons(function() { z = y(x.v); reZ(); s.v = z.v; callAll(s.h); }, x.h);
+ reZ();
+
+ return s;
+}
function dyn(s) {
var x = document.createElement("span");
x.innerHTML = s.v;
document.body.appendChild(x);
- s.h = { n : s.h, v : function() { x.innerHTML = s.v } };
+ s.h = cons(function() { x.innerHTML = s.v }, s.h);
}