Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit ff1c9ef

Browse files
spockeglennsl
authored andcommitted
added ofNode to Text (#164)
1 parent ffa8b27 commit ff1c9ef

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/Webapi/Webapi__Dom/Webapi__Dom__Text.re

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1+
let ofNode = (node: Dom.node) : option('a) =>
2+
Webapi__Dom__Node.nodeType(node) == Text ? Some(Obj.magic(node)) : None;
3+
14
module Impl = (T: {type t;}) => {
5+
let ofNode: Dom.node => option(T.t) = ofNode;
6+
27
[@bs.send.pipe : T.t] external splitText : (~offset: int, unit) => Dom.text = "";
38
[@bs.get] external wholeText : T.t => string = "";
49
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
open Webapi.Dom;
2+
3+
let node =
4+
document |> Document.createTextNode("text")
5+
|> Text.asNode;
6+
7+
let text = Text.ofNode(node);

0 commit comments

Comments
 (0)