From 6609c359d886000edb4dd9c9241faf6dd0fd379d Mon Sep 17 00:00:00 2001 From: Hayleigh Thompson Date: Sat, 11 May 2024 01:03:57 +0100 Subject: :bug: Fixed a bug where dynamic.classify has inconsistent behaviour between 0.36.0 and 0.37.0 --- src/lustre/internals/vdom.gleam | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/lustre/internals/vdom.gleam b/src/lustre/internals/vdom.gleam index 6363c9b..5d03b2b 100644 --- a/src/lustre/internals/vdom.gleam +++ b/src/lustre/internals/vdom.gleam @@ -114,6 +114,9 @@ pub fn attribute_to_json( attribute: Attribute(msg), key: String, ) -> Result(Json, Nil) { + let true_atom = dynamic.from(True) + let false_atom = dynamic.from(False) + case attribute { Attribute(_, _, True) -> Error(Nil) Attribute(name, value, as_property: False) -> { @@ -126,7 +129,15 @@ pub fn attribute_to_json( ]), ) - "Boolean" -> + "Atom" if value == true_atom || value == false_atom -> + Ok( + json.object([ + #("0", json.string(name)), + #("1", json.bool(dynamic.unsafe_coerce(value))), + ]), + ) + + "Bool" | "Boolean" -> Ok( json.object([ #("0", json.string(name)), -- cgit v1.2.3