diff options
author | Hayleigh Thompson <me@hayleigh.dev> | 2024-03-31 11:24:52 +0100 |
---|---|---|
committer | Hayleigh Thompson <me@hayleigh.dev> | 2024-03-31 11:24:52 +0100 |
commit | a38b93cbb6e75be285df673285d433fb00c77684 (patch) | |
tree | 959dbd5dd0be312805f8c1ac98fe989c909fc5b9 /src | |
parent | f45179f9124fb002e910afb618911c79a4a1549f (diff) | |
download | lustre-a38b93cbb6e75be285df673285d433fb00c77684.tar.gz lustre-a38b93cbb6e75be285df673285d433fb00c77684.zip |
:bug: Fixed a small bug where 'Map' nodes could not be keyed.
Diffstat (limited to 'src')
-rw-r--r-- | src/lustre/element.gleam | 32 |
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. /// |