aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHayleigh Thompson <me@hayleigh.dev>2024-03-31 11:24:52 +0100
committerHayleigh Thompson <me@hayleigh.dev>2024-03-31 11:24:52 +0100
commita38b93cbb6e75be285df673285d433fb00c77684 (patch)
tree959dbd5dd0be312805f8c1ac98fe989c909fc5b9
parentf45179f9124fb002e910afb618911c79a4a1549f (diff)
downloadlustre-a38b93cbb6e75be285df673285d433fb00c77684.tar.gz
lustre-a38b93cbb6e75be285df673285d433fb00c77684.zip
:bug: Fixed a small bug where 'Map' nodes could not be keyed.
-rw-r--r--src/lustre/element.gleam32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/lustre/element.gleam b/src/lustre/element.gleam
index c504ebf..412c7e3 100644
--- a/src/lustre/element.gleam
+++ b/src/lustre/element.gleam
@@ -164,23 +164,27 @@ pub fn keyed(
) -> Element(msg) {
el({
use #(key, child) <- list.map(children)
-
- case child {
- Element(_, namespace, tag, attrs, children, self_closing, void) ->
- Element(
- key: key,
- namespace: namespace,
- tag: tag,
- attrs: attrs,
- children: children,
- self_closing: self_closing,
- void: void,
- )
- _ -> child
- }
+ do_keyed(child, key)
})
}
+fn do_keyed(el: Element(msg), key: String) -> Element(msg) {
+ case el {
+ Element(_, namespace, tag, attrs, children, self_closing, void) ->
+ Element(
+ key: key,
+ namespace: namespace,
+ tag: tag,
+ attrs: attrs,
+ children: children,
+ self_closing: self_closing,
+ void: void,
+ )
+ Map(subtree) -> Map(fn() { do_keyed(subtree(), key) })
+ _ -> el
+ }
+}
+
/// A function for constructing elements in a specific XML namespace. This can
/// be used to construct SVG or MathML elements, for example.
///