Skip to content

Commit dbead22

Browse files
Make castHTMLNode public for use with Raw.WriteTo
1 parent 54453cc commit dbead22

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/Fable.React/Fable.Helpers.ReactServer.fs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -719,11 +719,13 @@ let rec private addReactMark htmlNode =
719719
HTMLNode.List (nodes |> Seq.cast |> Seq.map addReactMark |> Seq.cast)
720720
| h -> h
721721

722-
let inline private castHTMLNode (htmlNode: ReactElement): HTMLNode =
723-
if isNull htmlNode then
724-
HTMLNode.Empty
725-
else
726-
htmlNode :?> HTMLNode
722+
/// Cast a ReactElement safely to an HTMLNode.
723+
/// Returns an empty node if input is not an HTMLNode.
724+
let inline castHTMLNode (htmlNode: ReactElement): HTMLNode =
725+
match htmlNode with
726+
| :? HTMLNode as node -> node
727+
| _ -> HTMLNode.Empty
728+
727729

728730
module Raw =
729731
/// Writes the nodes into a TextWriter. DOESN'T ADD `reactroot` attribute.

0 commit comments

Comments
 (0)