aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHayleigh Thompson <me@hayleigh.dev>2023-09-12 18:38:41 +0100
committerHayleigh Thompson <me@hayleigh.dev>2023-09-12 18:38:41 +0100
commit89d864ce5a128dc96a7d90bfb42046de5a7902b7 (patch)
treee23d2e99ed5946013ae7ed901f23295cf6e91f57
parentd38e39c3f4e126e6470b8a2f97133977740efad8 (diff)
downloadlustre-89d864ce5a128dc96a7d90bfb42046de5a7902b7.tar.gz
lustre-89d864ce5a128dc96a7d90bfb42046de5a7902b7.zip
:bug: Fixed a bug where html void elements weren't rendered correctly as a string.
-rw-r--r--lib/src/lustre/element.gleam17
1 files changed, 17 insertions, 0 deletions
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)