From 89d864ce5a128dc96a7d90bfb42046de5a7902b7 Mon Sep 17 00:00:00 2001 From: Hayleigh Thompson Date: Tue, 12 Sep 2023 18:38:41 +0100 Subject: :bug: Fixed a bug where html void elements weren't rendered correctly as a string. --- lib/src/lustre/element.gleam | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/src/lustre/element.gleam b/lib/src/lustre/element.gleam index 69217f0..4608db7 100644 --- a/lib/src/lustre/element.gleam +++ b/lib/src/lustre/element.gleam @@ -89,6 +89,23 @@ pub fn to_string(element: Element(msg)) -> String { pub fn to_string_builder(element: Element(msg)) -> StringBuilder { case element { Text(content) -> string_builder.from_string(escape("", content)) + Element("area" as tag, attrs, _) + | Element("base" as tag, attrs, _) + | Element("br" as tag, attrs, _) + | Element("col" as tag, attrs, _) + | Element("embed" as tag, attrs, _) + | Element("hr" as tag, attrs, _) + | Element("img" as tag, attrs, _) + | Element("input" as tag, attrs, _) + | Element("link" as tag, attrs, _) + | Element("meta" as tag, attrs, _) + | Element("param" as tag, attrs, _) + | Element("source" as tag, attrs, _) + | Element("track" as tag, attrs, _) + | Element("wbr" as tag, attrs, _) -> + string_builder.from_string("<" <> tag) + |> attrs_to_string_builder(attrs) + |> string_builder.append(">") Element(tag, attrs, children) -> string_builder.from_string("<" <> tag) |> attrs_to_string_builder(attrs) -- cgit v1.2.3