Permalink
Browse files

Make JSHandle.asElement() return an option

More idiomatic to handle options rather than a nullable.

Override asElement in ElementHandle as it doesn't return null.

Also space out the function definitions now that whitespace is retained
by refmt in these modules.
  • Loading branch information...
zploskey committed Jun 8, 2018
1 parent fdaee4a commit c6a63adf5a5e6d647b6481e80d5daae8221b093c
Showing with 10 additions and 1 deletion.
  1. +3 −0 src/ElementHandle.re
  2. +7 −1 src/JSHandle.re
@@ -6,6 +6,9 @@ include JSHandle.Impl({

external empty : unit => t = "%identity";

/* Overrides asElement of JSHandle. Guaranteed to return an ElementHandle. */
[@bs.send] external asElement : t => Types.elementHandle = "";

[@bs.send]
external boundingBox : t => Js.Promise.t(Js.Null.t(BoundingBox.t)) = "";

@@ -1,11 +1,17 @@
module Impl = (T: {type t;}) => {
[@bs.send] external asElement : T.t => Js.null(Types.elementHandle) = "";
[@bs.send] [@bs.return nullable]
external asElement : T.t => option(Types.elementHandle) = "";

[@bs.send] external dispose : T.t => Js.Promise.t(unit) = "";

[@bs.send] external executionContext : T.t => Types.executionContext = "";

[@bs.send]
external getProperties : T.t => Js.Promise.t(JSMap.t(string, T.t)) = "";

[@bs.send.pipe: T.t]
external getProperty : (~propertyName: string) => Js.Promise.t(T.t) = "";

[@bs.send] external jsonValue : T.t => Js.Promise.t(Js.t({..})) = "";
};

0 comments on commit c6a63ad

Please sign in to comment.