Skip to content

Commit ef55dcb

Browse files
zaaackalfonsogarciacaro
authored andcommitted
Fix ssr warning
1 parent f6b966d commit ef55dcb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ open Fable.Helpers.React.Props
1111
// Adapted from https://github.com/emotion-js/emotion/blob/182e34bab2b2028c96d513b67ed86faee1b642b2/packages/emotion-utils/src/index.js#L13
1212
let private unitlessCssProps = set [ "animation-iteration-count"; "border-image-outset"; "border-image-slice"; "border-image-width"; "box-flex"; "box-flex-group"; "box-ordinal-group"; "column-count"; "columns"; "flex"; "flex-grow"; "flex-positive"; "flex-shrink"; "flex-negative"; "flex-order"; "grid-row"; "grid-row-end"; "grid-row-span"; "grid-row-start"; "grid-column"; "grid-column-end"; "grid-column-span"; "grid-column-start"; "font-weight"; "line-height"; "opacity"; "order"; "orphans"; "tab-size"; "widows"; "z-index"; "zoom"; "-webkit-line-clamp"; "fill-opacity"; "flood-opacity"; "stop-opacity"; "stroke-dasharray"; "stroke-dashoffset"; "stroke-miterlimit"; "stroke-opacity"; "stroke-width" ]
1313

14+
let private voidTags = set ["area"; "base"; "br"; "col"; "embed"; "hr"; "img"; "input"; "keygen"; "link"; "menuitem"; "meta"; "param"; "source"; "track"; "wbr"]
15+
1416
// Adapted from https://github.com/facebook/react/blob/37e4329bc81def4695211d6e3795a654ef4d84f5/packages/react-dom/src/server/escapeTextForBrowser.js#L49
1517
let escapeHtml (str: string) =
1618
let escaped = StringBuilder()
@@ -739,7 +741,9 @@ let renderToString (htmlNode: ReactElement): string =
739741
| Some c -> c
740742
| None -> (renderList (children |> Seq.map castHTMLNode))
741743
let attrs = if attrs = "" then attrs else " " + attrs
742-
"<" + tag + attrs + ">" + child + "</" + tag + ">"
744+
if voidTags |> Set.contains tag
745+
then "<" + tag + attrs + "/>"
746+
else "<" + tag + attrs + ">" + child + "</" + tag + ">"
743747
| HTMLNode.List nodes -> renderList (nodes |> Seq.cast)
744748
| HTMLNode.Empty -> ""
745749

0 commit comments

Comments
 (0)