Skip to content

Commit efa6060

Browse files
committed
fix: skip nested markup containers
1 parent 9d78582 commit efa6060

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/react-from-markup/src/rehydrator.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,13 @@ export default async (
7575
const roots = Array.from(
7676
// TODO: allow setting a container identifier so multiple rehydration instances can exist
7777
container.querySelectorAll("[data-react-from-markup-container]")
78-
);
78+
).reduce((acc: Element[], root: Element) => {
79+
// filter roots that are contained within other roots
80+
if (!acc.some(r => r.contains(root))) {
81+
acc.push(root);
82+
}
83+
return acc;
84+
}, []);
7985

8086
// TODO: solve race condition when a second rehydrate runs
8187

0 commit comments

Comments
 (0)