summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2011-01-16 10:57:59 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2011-01-16 10:57:59 -0500
commit9b03b47f0cb7072f24af0b5f067f461ee19a8894 (patch)
tree21d1cd652ab88106955b52bb46933daa4ec07a9f
parentfbc17fa1d962150062aa0b4839d75a27605b965e (diff)
Fix for handling of some attributes to client-side input widgets, based on a patch from Vladimir Shabanov
-rw-r--r--src/monoize.sml39
-rw-r--r--tests/vlad4.ur6
2 files changed, 28 insertions, 17 deletions
diff --git a/src/monoize.sml b/src/monoize.sml
index 4295811a..e7354e98 100644
--- a/src/monoize.sml
+++ b/src/monoize.sml
@@ -3100,28 +3100,33 @@ fun monoExp (env, st, fm) (all as (e, loc)) =
| ("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)
diff --git a/tests/vlad4.ur b/tests/vlad4.ur
new file mode 100644
index 00000000..d2bd14ef
--- /dev/null
+++ b/tests/vlad4.ur
@@ -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>