Skip to content

Commit 32bb55a

Browse files
fix: preact 10.22.1 contains error (#2596)
Fixes #2587
1 parent 9903576 commit 32bb55a

File tree

5 files changed

+28
-8
lines changed

5 files changed

+28
-8
lines changed

.vscode/import_map.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
"$fresh/": "../",
77
"twind": "https://esm.sh/[email protected]",
88
"twind/": "https://esm.sh/[email protected]/",
9-
"preact": "https://esm.sh/[email protected].0",
10-
"preact/": "https://esm.sh/[email protected].0/",
11-
"@preact/signals": "https://esm.sh/*@preact/signals@1.2.2",
12-
"@preact/signals-core": "https://esm.sh/@preact/signals-core@1.5.1",
9+
"preact": "https://esm.sh/[email protected].1",
10+
"preact/": "https://esm.sh/[email protected].1/",
11+
"@preact/signals": "https://esm.sh/*@preact/signals@1.3.0",
12+
"@preact/signals-core": "https://esm.sh/@preact/signals-core@1.7.0",
1313
"@preact/[email protected]": "https://esm.sh/@preact/[email protected]",
1414
"@preact/[email protected]": "https://esm.sh/@preact/[email protected]",
1515
"$prism": "https://esm.sh/[email protected]",

src/runtime/entrypoints/main.ts

+14-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function createRootFragment(
3636
endMarker: Text | Comment,
3737
) {
3838
// @ts-ignore this is fine
39-
return parent.__k = {
39+
const rootFrag = parent.__k = {
4040
_frshRootFrag: true,
4141
nodeType: 1,
4242
parentNode: parent,
@@ -70,7 +70,20 @@ function createRootFragment(
7070
removeChild(child: Node) {
7171
parent.removeChild(child);
7272
},
73+
contains(node: Node | null): boolean {
74+
if (node === null) return false;
75+
76+
const children = rootFrag.childNodes;
77+
for (let i = 0; i < children.length; i++) {
78+
if (children[i].contains(node)) {
79+
return true;
80+
}
81+
}
82+
return false;
83+
},
7384
};
85+
86+
return rootFrag;
7487
}
7588

7689
function isCommentNode(node: Node): node is Comment {

tests/fixture/deno.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"lock": false,
33
"imports": {
44
"$fresh/": "../../",
5-
"preact": "https://esm.sh/[email protected].0",
6-
"preact/": "https://esm.sh/[email protected].0/",
5+
"preact": "https://esm.sh/[email protected].1",
6+
"preact/": "https://esm.sh/[email protected].1/",
77
"@preact/signals": "https://esm.sh/*@preact/[email protected]",
88
"@preact/signals-core": "https://esm.sh/@preact/[email protected]"
99
},

tests/fixture/fresh.gen.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ import * as $folder_subfolder_Counter from "./islands/folder/subfolder/Counter.t
103103
import * as $kebab_case_counter_test from "./islands/kebab-case-counter-test.tsx";
104104
import * as $route_groups_islands_islands_Counter from "./routes/route-groups-islands/(_islands)/Counter.tsx";
105105
import * as $route_groups_islands_islands_invalid from "./routes/route-groups-islands/(_islands)/invalid.tsx";
106-
import { type Manifest } from "$fresh/server.ts";
106+
import type { Manifest } from "$fresh/server.ts";
107107

108108
const manifest = {
109109
routes: {

tests/islands_test.ts

+7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ import {
1212

1313
Deno.test("island tests", async (t) => {
1414
await withPage(async (page, address) => {
15+
const logs = [];
16+
page.on("pageerror", (ev) => {
17+
logs.push(ev.message);
18+
});
19+
1520
async function counterTest(counterId: string, originalValue: number) {
1621
const pElem = await page.waitForSelector(`#${counterId} > p`);
1722

@@ -46,6 +51,8 @@ Deno.test("island tests", async (t) => {
4651
?.[1]!;
4752
assertStringIncludes(srcString, imgFilePath);
4853
});
54+
55+
assertEquals(logs.length, 0, "No error logs");
4956
});
5057
});
5158

0 commit comments

Comments
 (0)