feat: support conditional island JSX children (#1355)

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
This commit is contained in:
Marvin Hagemeister
2023-08-08 11:35:28 +02:00
committed by GitHub
co-authored by Asher Gomez
parent dff80d3a42
commit 11077227b5
8 changed files with 205 additions and 49 deletions
+39 -6
View File
@@ -406,14 +406,10 @@ Deno.test({
await delay(100);
await page.click("button");
const text = await page.$eval(
"#page",
(el) => el.textContent,
);
// Button text is matched too, but this allows us
// to assert correct ordering. The "it works" should
// to assert correct ordering. The "island content" should
// be left of "Toggle"
assertEquals(text, "it worksToggle");
await waitForText(page, "#page", "island contentToggle");
},
);
},
@@ -478,3 +474,40 @@ Deno.test({
sanitizeOps: false,
sanitizeResources: false,
});
Deno.test({
name: "render nested islands with server children conditionally",
async fn() {
await withPageName(
"./tests/fixture_island_nesting/main.ts",
async (page, address) => {
await page.goto(`${address}/island_conditional_lazy`);
await waitForText(page, ".island p", "island content");
await page.click("button");
await waitForText(page, ".island p", "server rendered");
},
);
},
});
Deno.test({
name: "revive island in lazy server rendered children conditionally",
async fn() {
await withPageName(
"./tests/fixture_island_nesting/main.ts",
async (page, address) => {
await page.goto(`${address}/island_conditional_lazy_island`);
await waitForText(page, ".island p", "island content");
await page.click("button");
await waitForText(page, ".island .server", "server rendered");
await page.click("button.counter");
await waitForText(page, ".island .count", "1");
},
);
},
});