Skip to content

Commit

Permalink
Do not use physical equality on JavaScript values
Browse files Browse the repository at this point in the history
  • Loading branch information
vouillon committed Oct 6, 2023
1 parent bbeacae commit 0656e75
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/widgets/ot_carousel.eliom
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,9 @@ let%shared make ?(a = []) ?(vertical = false) ?(position = 0)
(Js.Unsafe.coerce d2'##.style)##.webkitTransform := s;
let move =
not
(before == (Js.Unsafe.coerce d2'##.style)##.transform
|| before == (Js.Unsafe.coerce d2'##.style)##.webkitTransform)
(Js.strict_equals before (Js.Unsafe.coerce d2'##.style)##.transform
|| Js.strict_equals before
(Js.Unsafe.coerce d2'##.style)##.webkitTransform)
in
let step = React.Step.create () in
pos_set ~step pos;
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/ot_lib.eliom
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ let%client window_scrolls ?(ios_html_scroll_hack = false) ?use_capture handler =
(fun () -> stop_thread (); Lwt.cancel !cur; Lwt.return_unit)

let%client rec in_ancestors ~elt ~ancestor =
elt == (ancestor : Dom_html.element Js.t)
|| (not (elt == Dom_html.document##.body))
Js.strict_equals elt (ancestor : Dom_html.element Js.t)
|| (not (Js.strict_equals elt Dom_html.document##.body))
&& Js.Opt.case elt##.parentNode
(fun () -> false)
(fun parent ->
Expand Down
8 changes: 5 additions & 3 deletions src/widgets/ot_nodeready.eliom
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ open Js_of_ocaml
let debug = false

let rec node_in_document node =
node == (Dom_html.document :> Dom.node Js.t)
Js.strict_equals node (Dom_html.document :> Dom.node Js.t)
|| Js.Opt.case node##.parentNode (fun () -> false) node_in_document

type t =
Expand Down Expand Up @@ -81,7 +81,9 @@ let nodeready n =
else (
if !watched = [] then observer##observe Dom_html.document config;
try
let {thread} = List.find (fun {node} -> n == node) !watched in
let {thread} =
List.find (fun {node} -> Js.strict_equals n node) !watched
in
log ~n "already being watched";
thread
with Not_found ->
Expand All @@ -93,7 +95,7 @@ let nodeready n =
in
Eliom_client.Page_status.ondead ~stop (fun () ->
let instances_of_node, rest =
List.partition (fun {node} -> n == node) !watched
List.partition (fun {node} -> Js.strict_equals n node) !watched
in
watched := rest;
instances_of_node
Expand Down

0 comments on commit 0656e75

Please sign in to comment.