changeset 1398:fe470db7feea

Fix for handling of some attributes to client-side input widgets, based on a patch from Vladimir Shabanov
author Adam Chlipala <adam@chlipala.net>
date Sun, 16 Jan 2011 10:57:59 -0500
parents a5bfed32d4f7
children 898dc978c39d
files src/monoize.sml tests/vlad4.ur
diffstat 2 files changed, 28 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/monoize.sml	Sun Jan 16 10:38:03 2011 -0500
+++ b/src/monoize.sml	Sun Jan 16 10:57:59 2011 -0500
@@ -3100,28 +3100,33 @@
                                        | ("Onchange", e, _) =>
                                          SOME (strcat [str "addOnChange(d,exec(",
                                                        (L'.EJavaScript (L'.Script, e), loc),
-                                                       str "))"])
+                                                       str "));"])
                                        | (x, e, (L'.TFun ((L'.TRecord [], _), _), _)) =>
                                          SOME (strcat [str ("d." ^ lowercaseFirst x ^ "=exec("),
                                                        (L'.EJavaScript (L'.Script, e), loc),
                                                        str ");"])
                                        | (x, e, _) =>
-                                         let
-                                             val e = (L'.EAbs ("_", (L'.TRecord [], loc), (L'.TRecord [], loc),
-                                                               (L'.EApp ((L'.EApp (liftExpInExp 0 e,
-                                                                                   (L'.EFfiApp ("Basis", "kc", []), loc)),
-                                                                          loc), (L'.ERecord [], loc)), loc)), loc)
-                                         in
-                                             case x of
-                                                 "Onkeyup" =>
-                                                 SOME (strcat [str ("((function(c){addOnKeyUp(d,function(){window.uw_event=window.event;return c();});})(exec("),
-                                                               (L'.EJavaScript (L'.Script, e), loc),
-                                                               str ")));"])
-                                               | _ =>
-                                                 SOME (strcat [str ("((function(c){d." ^ lowercaseFirst x ^ "=function(){window.uw_event=window.event;return c();};})(exec("),
-                                                               (L'.EJavaScript (L'.Script, e), loc),
-                                                               str ")));"])
-                                         end)
+                                         if String.isPrefix "On" x then
+                                             let
+                                                 val e = (L'.EAbs ("_", (L'.TRecord [], loc), (L'.TRecord [], loc),
+                                                                   (L'.EApp ((L'.EApp (liftExpInExp 0 e,
+                                                                                       (L'.EFfiApp ("Basis", "kc", []), loc)),
+                                                                              loc), (L'.ERecord [], loc)), loc)), loc)
+                                             in
+                                                 case x of
+                                                     "Onkeyup" =>
+                                                     SOME (strcat [str ("((function(c){addOnKeyUp(d,function(){window.uw_event=window.event;return c();});})(exec("),
+                                                                   (L'.EJavaScript (L'.Script, e), loc),
+                                                                   str ")));"])
+                                                   | _ =>
+                                                     SOME (strcat [str ("((function(c){d." ^ lowercaseFirst x ^ "=function(){window.uw_event=window.event;return c();};})(exec("),
+                                                                   (L'.EJavaScript (L'.Script, e), loc),
+                                                                   str ")));"])
+                                             end
+                                         else
+                                             SOME (strcat [str ("d." ^ lowercaseFirst x ^ "=exec("),
+                                                           (L'.EJavaScript (L'.Script, e), loc),
+                                                           str ");"]))
                                      attrs
 
                         val t = (L'.TFfi ("Basis", "string"), loc)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/vlad4.ur	Sun Jan 16 10:57:59 2011 -0500
@@ -0,0 +1,6 @@
+fun main () : transaction page =
+    s <- source "";
+    return <xml><body>
+      <ctextbox source={s} value="123" onchange={s <- get s; alert (s ^ "!")}/>
+      <dyn signal={s <- signal s; return (txt s)}/>
+    </body></xml>