Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[enhance] xhtml.opa: generated dom id are much shorter now

  • Loading branch information...
commit ca0f2c54583400248cd2f6df342ba89415231558 1 parent c1a63a8
@OpaOnWindowsNow OpaOnWindowsNow authored
View
2  libbase/identGenerator.ml
@@ -54,7 +54,7 @@ let alphanum =
assert(int_to_char zero_pos='0');
- let rec name_of_int i =
+ let name_of_int i =
let to_char_list i n =
let rec aux i n acc =
if n<=0 then acc
View
2  opabsl/mlbsl/bsl-sources
@@ -42,6 +42,8 @@ bslInit.ml
bslClientCode.ml
bslClientEvent.ml
+bslIdentGen.ml # xhtml ident
+
bslServer_event.ml
# Database handling
View
2  opabsl/mlbsl/bslIdentGen.ml
@@ -0,0 +1,2 @@
+##register create : string -> (-> string)
+let create prefix = IdentGenerator.alphanum_generator ~prefix
View
17 stdlib/core/xhtml/xhtml.opa
@@ -684,6 +684,19 @@ Xhtml =
to_string = serialize_to_string
+ @publish new_server_id =
+ nid = (%% bslIdentGen.create %%)("I8")
+ nid
+
+ new_id: -> string =
+ @sliced_expr(
+ {
+ client() = Random.string(16)
+ server = new_server_id
+ }
+ )
+
+
@private Buf = Buffer2_private
/**
@@ -792,7 +805,7 @@ Xhtml =
id = match find_attr("id", args) with
| ~{some} -> some
| {none} ->
- id = Random.string(32) //Generate a random ID
+ id = new_id()
do print_arg(sassoc("id", id))
id
end
@@ -1066,7 +1079,7 @@ Xhtml =
* When the future position of the id is not clear (several possible node), it encapsulated everything in a div
*/
add_id(id,x:xhtml):xhtml =
- id = id ? Random.string(16)
+ id = id ? new_id()
// aux(id, x) with
rec aux(id,x)=
match x : xhtml
Please sign in to comment.
Something went wrong with that request. Please try again.