Skip to content

Commit e571a0d

Browse files
fix: disable client-side <Head>component until perf issue is fixed
1 parent 8717fb8 commit e571a0d

1 file changed

Lines changed: 43 additions & 40 deletions

File tree

packages/fresh/src/runtime/client/preact_hooks_client.ts

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -37,53 +37,56 @@ options.vnode = (vnode) => {
3737
case "base":
3838
case "noscript":
3939
case "template":
40-
// deno-lint-ignore no-explicit-any
41-
vnode.type = (props: any) => {
42-
useEffect(() => {
43-
const text = renderToString(h(Fragment, null, props.children));
44-
45-
if (originalType === "title") {
46-
document.title = text;
47-
return;
48-
}
49-
50-
let matched: HTMLElement | null = null;
51-
if (vnode.key) {
52-
matched = document.head.querySelector(
53-
`head [data-key="${vnode.key}"]`,
54-
) as HTMLElement ?? null;
55-
}
56-
57-
if (matched === null && props.id) {
58-
matched = document.head.querySelector(
59-
`#${props.name}`,
60-
) as HTMLElement ??
61-
null;
62-
}
63-
64-
if (matched === null) {
65-
if (originalType === "meta") {
40+
// deno-lint-ignore no-constant-condition
41+
if (false) {
42+
// deno-lint-ignore no-explicit-any
43+
vnode.type = (props: any) => {
44+
useEffect(() => {
45+
const text = renderToString(h(Fragment, null, props.children));
46+
47+
if (originalType === "title") {
48+
document.title = text;
49+
return;
50+
}
51+
52+
let matched: HTMLElement | null = null;
53+
if (vnode.key) {
6654
matched = document.head.querySelector(
67-
`head [name="${props.name}"]`,
55+
`head [data-key="${vnode.key}"]`,
6856
) as HTMLElement ?? null;
69-
} else if (originalType === "base") {
70-
matched = document.head.querySelector(originalType) ?? null;
7157
}
72-
}
7358

74-
if (matched === null) {
75-
matched = document.createElement(originalType);
76-
}
59+
if (matched === null && props.id) {
60+
matched = document.head.querySelector(
61+
`#${props.name}`,
62+
) as HTMLElement ??
63+
null;
64+
}
7765

78-
if (matched.textContent !== text) {
79-
matched.textContent = text;
80-
}
66+
if (matched === null) {
67+
if (originalType === "meta") {
68+
matched = document.head.querySelector(
69+
`head [name="${props.name}"]`,
70+
) as HTMLElement ?? null;
71+
} else if (originalType === "base") {
72+
matched = document.head.querySelector(originalType) ?? null;
73+
}
74+
}
75+
76+
if (matched === null) {
77+
matched = document.createElement(originalType);
78+
}
79+
80+
if (matched.textContent !== text) {
81+
matched.textContent = text;
82+
}
8183

82-
applyProps(props, matched);
83-
}, []);
84+
applyProps(props, matched);
85+
}, []);
8486

85-
return null;
86-
};
87+
return null;
88+
};
89+
}
8790
break;
8891
}
8992
}

0 commit comments

Comments
 (0)