Skip to content

Commit

Permalink
Adapt to Dom_html changes
Browse files Browse the repository at this point in the history
  • Loading branch information
vouillon committed Dec 13, 2024
1 parent a181f88 commit a09f3b8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 33 deletions.
21 changes: 6 additions & 15 deletions src/lib/client/eliommod_cookies.ml
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,10 @@ let get_table ?(in_local_storage = false) = function
if in_local_storage
then
let host = Js.string (host ^ "/substitutes") in
Js.Optdef.case
Dom_html.window##.localStorage
Js.Opt.case
Dom_html.window ##. localStorage ## (getItem host)
(fun () -> Ocsigen_cookie_map.Map_path.empty)
(fun st ->
Js.Opt.case
st ## (getItem host)
(fun () -> Ocsigen_cookie_map.Map_path.empty)
(fun v ->
intern_cookies (of_json ~typ:json_cookies (Js.to_string v))))
(fun v -> intern_cookies (of_json ~typ:json_cookies (Js.to_string v)))
else
Js.Optdef.get
(Jstable.find cookie_tables (Js.string host))
Expand All @@ -162,13 +157,9 @@ let set_table ?(in_local_storage = false) host t =
if in_local_storage
then
let host = Js.string (host ^ "/substitutes") in
Js.Optdef.case
Dom_html.window##.localStorage
(fun () -> ())
(fun st ->
st
## (setItem host
(Js.string (to_json ~typ:json_cookies (extern_cookies t)))))
Dom_html.window ##. localStorage
## (setItem host
(Js.string (to_json ~typ:json_cookies (extern_cookies t))))
else Jstable.add cookie_tables (Js.string host) t

let now () =
Expand Down
19 changes: 4 additions & 15 deletions src/lib/eliom_client.client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -817,23 +817,13 @@ let state_key {session_id; state_index} =

let get_state state_id : state =
Js.Opt.case
(Js.Optdef.case
Dom_html.window##.sessionStorage
(fun () ->
(* We use this only when the history API is
available. Sessionstorage seems to be available
everywhere the history API exists. *)
Lwt_log.raise_error_f ~section "sessionStorage not available")
(fun s -> s ## (getItem (state_key state_id))))
Dom_html.window ##. sessionStorage ## (getItem (state_key state_id))
(fun () -> raise Not_found)
(fun s -> of_json ~typ:[%json: state] (Js.to_string s))

let set_state i (v : state) =
Js.Optdef.case
Dom_html.window##.sessionStorage
(fun () -> ())
(fun s ->
s ## (setItem (state_key i) (Js.string (to_json ~typ:[%json: state] v))))
Dom_html.window ##. sessionStorage
## (setItem (state_key i) (Js.string (to_json ~typ:[%json: state] v)))

let update_state () =
set_state !active_page.page_id
Expand Down Expand Up @@ -866,8 +856,7 @@ let insert_base page =

let get_global_data () =
let def () = None and id = Js.string "__global_data" in
Js.Optdef.case Dom_html.window##.localStorage def @@ fun storage ->
Js.Opt.case storage ## (getItem id) def @@ fun v ->
Js.Opt.case Dom_html.window ##. localStorage ## (getItem id) def @@ fun v ->
Lwt_log.ign_debug_f "Unwrap __global_data";
match Eliom_unwrap.unwrap (Url.decode (Js.to_string v)) 0 with
| {Eliom_runtime.ecs_data = `Success v; _} ->
Expand Down
2 changes: 1 addition & 1 deletion src/lib/eliom_content.client.mli
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ module Html : sig
val minHeightPx : 'a elt -> int
val minWidth : 'a elt -> string
val minWidthPx : 'a elt -> int
val opacity : 'a elt -> string option
val opacity : 'a elt -> string
val outline : 'a elt -> string
val outlineColor : 'a elt -> string
val outlineOffset : 'a elt -> string
Expand Down
4 changes: 2 additions & 2 deletions src/lib/eliom_content_.client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ module Html = struct

let opacity elt =
let elt = get_unique_elt "Css.opacity" elt in
Option.map Js.to_bytestring (Js.Optdef.to_option elt##.style##.opacity)
Js.to_bytestring elt##.style##.opacity

let outline elt =
let elt = get_unique_elt "Css.outline" elt in
Expand Down Expand Up @@ -1406,7 +1406,7 @@ module Html = struct

let opacity elt v =
let elt = get_unique_elt "SetCss.opacity" elt in
elt##.style##.opacity := Js.def (Js.bytestring v)
elt##.style##.opacity := Js.bytestring v

let outline elt v =
let elt = get_unique_elt "SetCss.outline" elt in
Expand Down

0 comments on commit a09f3b8

Please sign in to comment.