aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Hivert <hivert.is.coming@gmail.com>2024-06-30 19:11:59 +0200
committerGitHub <noreply@github.com>2024-06-30 19:11:59 +0200
commitc12908cbf31f553b5ec628755b6a6c3b0ce72fdc (patch)
tree8abfe665fad93c7f012cda9785d878a937eb7d13 /src
parentf0d8e80229002bfa190b5b30b6a45d0ac66b27be (diff)
downloadlustre-c12908cbf31f553b5ec628755b6a6c3b0ce72fdc.tar.gz
lustre-c12908cbf31f553b5ec628755b6a6c3b0ce72fdc.zip
:bug: Fix when a Fragment is put in VDOM stack, because of Map (#154)HEADmain
Diffstat (limited to 'src')
-rw-r--r--src/vdom.ffi.mjs11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/vdom.ffi.mjs b/src/vdom.ffi.mjs
index 0c645c1..58f1e53 100644
--- a/src/vdom.ffi.mjs
+++ b/src/vdom.ffi.mjs
@@ -553,16 +553,19 @@ function diffKeyedChild(
return prevChild;
}
-/*
- Iterate element, helper to apply the same functions to a standard "Element" or "Fragment" transparently
- 1. If single element, call callback for that element
- 2. If fragment, call callback for every child element. Fragment constructor guarantees no Fragment children
+/**
+ Iterate element, helper to apply the same functions to a standard `Element`, `Fragment` or `Map` transparently
+ 1. If single `Element`, call callback for that element
+ 2. If `Fragment`, call callback for every child element. Fragment constructor guarantees no Fragment children
+ 3. If `Map`, compute the subtree and call callback for every child element. This case happens when using an `element.map` on a `Fragment`.
*/
function iterateElement(element, processElement) {
if (element.elements !== undefined) {
for (const currElement of element.elements) {
processElement(currElement);
}
+ } else if (element.subtree !== undefined) {
+ iterateElement(element.subtree(), processElement);
} else {
processElement(element);
}