Skip to content

Commit

Permalink
fix: preact 10.22.1 contains error (#2596)
Browse files Browse the repository at this point in the history
Fixes #2587
  • Loading branch information
marvinhagemeister authored Aug 15, 2024
1 parent 9903576 commit 32bb55a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 8 deletions.
8 changes: 4 additions & 4 deletions .vscode/import_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"$fresh/": "../",
"twind": "https://esm.sh/[email protected]",
"twind/": "https://esm.sh/[email protected]/",
"preact": "https://esm.sh/[email protected].0",
"preact/": "https://esm.sh/[email protected].0/",
"@preact/signals": "https://esm.sh/*@preact/signals@1.2.2",
"@preact/signals-core": "https://esm.sh/@preact/signals-core@1.5.1",
"preact": "https://esm.sh/[email protected].1",
"preact/": "https://esm.sh/[email protected].1/",
"@preact/signals": "https://esm.sh/*@preact/signals@1.3.0",
"@preact/signals-core": "https://esm.sh/@preact/signals-core@1.7.0",
"@preact/[email protected]": "https://esm.sh/@preact/[email protected]",
"@preact/[email protected]": "https://esm.sh/@preact/[email protected]",
"$prism": "https://esm.sh/[email protected]",
Expand Down
15 changes: 14 additions & 1 deletion src/runtime/entrypoints/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function createRootFragment(
endMarker: Text | Comment,
) {
// @ts-ignore this is fine
return parent.__k = {
const rootFrag = parent.__k = {
_frshRootFrag: true,
nodeType: 1,
parentNode: parent,
Expand Down Expand Up @@ -70,7 +70,20 @@ function createRootFragment(
removeChild(child: Node) {
parent.removeChild(child);
},
contains(node: Node | null): boolean {
if (node === null) return false;

const children = rootFrag.childNodes;
for (let i = 0; i < children.length; i++) {
if (children[i].contains(node)) {
return true;
}
}
return false;
},
};

return rootFrag;
}

function isCommentNode(node: Node): node is Comment {
Expand Down
4 changes: 2 additions & 2 deletions tests/fixture/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"lock": false,
"imports": {
"$fresh/": "../../",
"preact": "https://esm.sh/[email protected].0",
"preact/": "https://esm.sh/[email protected].0/",
"preact": "https://esm.sh/[email protected].1",
"preact/": "https://esm.sh/[email protected].1/",
"@preact/signals": "https://esm.sh/*@preact/[email protected]",
"@preact/signals-core": "https://esm.sh/@preact/[email protected]"
},
Expand Down
2 changes: 1 addition & 1 deletion tests/fixture/fresh.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ import * as $folder_subfolder_Counter from "./islands/folder/subfolder/Counter.t
import * as $kebab_case_counter_test from "./islands/kebab-case-counter-test.tsx";
import * as $route_groups_islands_islands_Counter from "./routes/route-groups-islands/(_islands)/Counter.tsx";
import * as $route_groups_islands_islands_invalid from "./routes/route-groups-islands/(_islands)/invalid.tsx";
import { type Manifest } from "$fresh/server.ts";
import type { Manifest } from "$fresh/server.ts";

const manifest = {
routes: {
Expand Down
7 changes: 7 additions & 0 deletions tests/islands_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ import {

Deno.test("island tests", async (t) => {
await withPage(async (page, address) => {
const logs = [];
page.on("pageerror", (ev) => {
logs.push(ev.message);
});

async function counterTest(counterId: string, originalValue: number) {
const pElem = await page.waitForSelector(`#${counterId} > p`);

Expand Down Expand Up @@ -46,6 +51,8 @@ Deno.test("island tests", async (t) => {
?.[1]!;
assertStringIncludes(srcString, imgFilePath);
});

assertEquals(logs.length, 0, "No error logs");
});
});

Expand Down

0 comments on commit 32bb55a

Please sign in to comment.