From ff903ab203a5371dffe5e3dd2e69e5e4fb8af027 Mon Sep 17 00:00:00 2001 From: Hayleigh Thompson Date: Sat, 21 Oct 2023 17:16:48 +0100 Subject: :bug: Fixed bug where attribute.to_string_builder didnt emit bool attributes properly. --- src/lustre/attribute.gleam | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/lustre/attribute.gleam b/src/lustre/attribute.gleam index 3b7ec70..e71636c 100644 --- a/src/lustre/attribute.gleam +++ b/src/lustre/attribute.gleam @@ -91,7 +91,7 @@ pub fn to_string_parts(attr: Attribute(msg)) -> Result(#(String, String), Nil) { /// pub fn to_string_builder(attr: Attribute(msg)) -> StringBuilder { case attr { - Attribute(name, value, as_property: False) -> { + Attribute(name, value, as_property) -> { case dynamic.classify(value) { "String" -> [name, "=\"", dynamic.unsafe_coerce(value), "\""] @@ -106,13 +106,12 @@ pub fn to_string_builder(attr: Attribute(msg)) -> StringBuilder { False -> string_builder.new() } - // For everything else we'll just make a best-effort serialisation. + _ if as_property -> string_builder.new() _ -> [name, "=\"", string.inspect(value), "\""] |> string_builder.from_strings } } - Attribute(_, _, as_property: True) -> string_builder.new() Event(on, _) -> ["data-lustre-on:", on] |> string_builder.from_strings -- cgit v1.2.3