Skip to content

Commit

Permalink
fix: nested children slots erroring (#2674)
Browse files Browse the repository at this point in the history
Fixes #2624
  • Loading branch information
marvinhagemeister authored Oct 4, 2024
1 parent ad82914 commit 75b5854
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 5 deletions.
6 changes: 1 addition & 5 deletions src/runtime/client/reviver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,11 +408,7 @@ export function domToVNode(
});

const parentVNode = vnodeStack.at(-1)!;
if (slotName === "children") {
addVNodeChild(parentVNode, vnode);
} else {
parentVNode.props[slotName] = vnode;
}
parentVNode.props[slotName] = vnode;
vnodeStack.push(vnode);
} else if (kind === "partial") {
sib = maybeHideMarker(sib);
Expand Down
44 changes: 44 additions & 0 deletions tests/islands_test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,50 @@ Deno.test({
sanitizeOps: false,
});

Deno.test({
name: "islands - nested children slots",
fn: async () => {
const passThrough = getIsland("PassThrough.tsx");
const selfCounter = getIsland("SelfCounter.tsx");

const app = testApp()
.use(staticFiles())
.island(passThrough, "PassThrough", PassThrough)
.island(selfCounter, "SelfCounter", SelfCounter)
.get("/", (ctx) => {
return ctx.render(
<Doc>
<PassThrough>
<PassThrough>
<div>
<SelfCounter id="a" />
</div>
</PassThrough>
<PassThrough>
<div>
<SelfCounter id="b" />
</div>
</PassThrough>
</PassThrough>
</Doc>,
);
});

await withBrowserApp(app, async (page, address) => {
await page.goto(address, { waitUntil: "load" });
await page.locator(".ready").wait();

await page.locator("#a .increment").click();
await page.locator("#b .increment").click();

await waitForText(page, "#a .output", "1");
await waitForText(page, "#b .output", "1");
});
},
sanitizeResources: false,
sanitizeOps: false,
});

Deno.test({
name: "islands - conditional jsx children",
fn: async () => {
Expand Down

0 comments on commit 75b5854

Please sign in to comment.