aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHayleigh Thompson <me@hayleigh.dev>2024-05-11 01:03:57 +0100
committerHayleigh Thompson <me@hayleigh.dev>2024-05-11 01:03:57 +0100
commit6609c359d886000edb4dd9c9241faf6dd0fd379d (patch)
treed6666055432b8509f651bd3966080680730fa541 /src
parentba58db799bae62c765302b335b45ac14cf1a4fdb (diff)
downloadlustre-6609c359d886000edb4dd9c9241faf6dd0fd379d.tar.gz
lustre-6609c359d886000edb4dd9c9241faf6dd0fd379d.zip
:bug: Fixed a bug where dynamic.classify has inconsistent behaviour between 0.36.0 and 0.37.0
Diffstat (limited to 'src')
-rw-r--r--src/lustre/internals/vdom.gleam13
1 files changed, 12 insertions, 1 deletions
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)),