summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/js/urweb.js2
-rw-r--r--src/c/urweb.c9
-rw-r--r--tests/id.ur11
3 files changed, 20 insertions, 2 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js
index 5a18e17c..74badd36 100644
--- a/lib/js/urweb.js
+++ b/lib/js/urweb.js
@@ -1731,7 +1731,7 @@ function bless(s) {
var nextId = 0;
function fresh() {
- return (--nextId).toString();
+ return "uw" + (--nextId);
}
diff --git a/src/c/urweb.c b/src/c/urweb.c
index dc6ef4e6..b105d5ff 100644
--- a/src/c/urweb.c
+++ b/src/c/urweb.c
@@ -3962,7 +3962,14 @@ void uw_cutErrorLocation(char *s) {
}
uw_Basis_string uw_Basis_fresh(uw_context ctx) {
- return uw_Basis_htmlifyInt(ctx, ctx->nextId++);
+ int len;
+ char *r;
+
+ uw_check_heap(ctx, 2+INTS_MAX);
+ r = ctx->heap.front;
+ sprintf(r, "uw%u%n", ctx->nextId++, &len);
+ ctx->heap.front += len+1;
+ return r;
}
uw_Basis_float uw_Basis_floatFromInt(uw_context ctx, uw_Basis_int n) {
diff --git a/tests/id.ur b/tests/id.ur
new file mode 100644
index 00000000..2178cf4f
--- /dev/null
+++ b/tests/id.ur
@@ -0,0 +1,11 @@
+fun main () : transaction page =
+ id1 <- fresh;
+ id2 <- fresh;
+ x <- source <xml/>;
+ return <xml><body>
+ <span id={id1}>Hi!</span>
+ <span id={id2}>Ho!</span>
+ <dyn signal={signal x}/>
+ <button value="Set" onclick={id <- fresh; set x <xml><span id={id}>He!</span></xml>}/>
+ <button value="Show" onclick={x <- get x; alert (show x)}/>
+ </body></xml>