changeset 571:86d324061ddc

Switch to using dyn() function in JavaScript
author Adam Chlipala <adamc@hcoop.net>
date Sun, 21 Dec 2008 12:01:00 -0500
parents af0df56ecc2c
children 57018f21cd5c
files jslib/urweb.js src/monoize.sml
diffstat 2 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/jslib/urweb.js	Sat Dec 20 18:24:12 2008 -0500
+++ b/jslib/urweb.js	Sun Dec 21 12:01:00 2008 -0500
@@ -1,1 +1,7 @@
 function sreturn(v) { return {v : v} }
+
+function dyn(s) {
+  var x = document.createElement("span");
+  x.innerHTML = s.v;
+  document.body.appendChild(x);
+}
--- a/src/monoize.sml	Sat Dec 20 18:24:12 2008 -0500
+++ b/src/monoize.sml	Sun Dec 21 12:01:00 2008 -0500
@@ -1850,20 +1850,14 @@
 
                   | "dyn" =>
                     (case #1 attrs of
-                         (*L'.ERecord [("Signal", (L'.ESignalReturn e, _), _)] => (e, fm)
-                       | L'.ERecord [("Signal", (L'.EApp ((L'.EAbs (_, _, _, (L'.ESignalReturn (L'.ERel 0, _), _)), _),
+                         (*L'.ERecord [("Signal", (L'.EApp ((L'.EAbs (_, _, _, (L'.ESignalReturn (L'.ERel 0, _), _)), _),
                                                           e), _), _)] => (e, fm) *)
 
                          L'.ERecord [("Signal", e, _)] =>
                          ((L'.EStrcat
-                               ((L'.EPrim (Prim.String "<script type=\"text/javascript\">"), loc),
-                                (L'.EStrcat ((L'.EJavaScript (L'.Script,
-                                                              (L'.ELet ("signal", (L'.TSignal
-                                                                                       (L'.TFfi ("Basis", "string"), loc),
-                                                                                   loc),
-                                                                        e,
-                                                                        (L'.EWrite (L'.ERel 0, loc), loc)), loc)), loc),
-                                             (L'.EPrim (Prim.String "</script>"), loc)), loc)), loc),
+                               ((L'.EPrim (Prim.String "<script type=\"text/javascript\">dyn("), loc),
+                                (L'.EStrcat ((L'.EJavaScript (L'.Script, e), loc),
+                                             (L'.EPrim (Prim.String ")</script>"), loc)), loc)), loc),
                           fm)
                        | _ => raise Fail "Monoize: Bad dyn attributes")