fix: falsy f-* attributes not preserved inside island (#2498)

Fixes https://github.com/denoland/fresh/issues/2359
This commit is contained in:
Marvin Hagemeister
2024-06-05 10:06:53 +02:00
committed by GitHub
parent fba3f2b845
commit 2b88f4bf56
5 changed files with 68 additions and 1 deletions
+31
View File
@@ -29,6 +29,7 @@ import * as path from "@std/path";
import { setBuildCache } from "../src/app.ts";
import { getBuildCache } from "../src/app.ts";
import type { FreshConfig } from "../src/config.ts";
import { FreshAttrs } from "./fixtures_islands/FreshAttrs.tsx";
await buildProd(allIslandApp);
@@ -601,6 +602,36 @@ Deno.test({
},
});
Deno.test({
name: "islands - preserve f-* attributes",
fn: async () => {
const freshAttrs = getIsland("FreshAttrs.tsx");
const app = testApp()
.use(staticFiles())
.island(freshAttrs, "FreshAttrs", FreshAttrs)
.get("/", (ctx) =>
ctx.render(
<Doc>
<FreshAttrs />
</Doc>,
));
await withBrowserApp(app, async (page, address) => {
await page.goto(address, { waitUntil: "load" });
await page.locator(".ready").wait();
const truthy = await page.locator<HTMLDivElement>(".f-client-nav-true")
.evaluate((el) => el.getAttribute("f-client-nav"));
const falsy = await page.locator<HTMLDivElement>(".f-client-nav-false")
.evaluate((el) => el.getAttribute("f-client-nav"));
expect(truthy).toEqual("true");
expect(falsy).toEqual("false");
});
},
});
Deno.test({
name: "fsRoutes - load islands from group folder",
fn: async () => {