fix: nested children slots erroring (#2674)

Fixes https://github.com/denoland/fresh/issues/2624
This commit is contained in:
Marvin Hagemeister
2024-10-04 05:05:27 +02:00
committed by GitHub
parent ad8291447a
commit 75b5854810
2 changed files with 45 additions and 5 deletions
+1 -5
View File
@@ -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);
+44
View File
@@ -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 () => {