fix: disable client-side <Head>component until perf issue is fixed (#3255)

Need to look at it in more detail tomorrow.
This commit is contained in:
Marvin Hagemeister
2025-08-25 18:45:56 +02:00
committed by GitHub
parent 8717fb8f77
commit 46ccff35c3
2 changed files with 48 additions and 41 deletions
@@ -37,53 +37,56 @@ options.vnode = (vnode) => {
case "base":
case "noscript":
case "template":
// deno-lint-ignore no-explicit-any
vnode.type = (props: any) => {
useEffect(() => {
const text = renderToString(h(Fragment, null, props.children));
// deno-lint-ignore no-constant-condition
if (false) {
// deno-lint-ignore no-explicit-any
vnode.type = (props: any) => {
useEffect(() => {
const text = renderToString(h(Fragment, null, props.children));
if (originalType === "title") {
document.title = text;
return;
}
let matched: HTMLElement | null = null;
if (vnode.key) {
matched = document.head.querySelector(
`head [data-key="${vnode.key}"]`,
) as HTMLElement ?? null;
}
if (matched === null && props.id) {
matched = document.head.querySelector(
`#${props.name}`,
) as HTMLElement ??
null;
}
if (matched === null) {
if (originalType === "meta") {
matched = document.head.querySelector(
`head [name="${props.name}"]`,
) as HTMLElement ?? null;
} else if (originalType === "base") {
matched = document.head.querySelector(originalType) ?? null;
if (originalType === "title") {
document.title = text;
return;
}
}
if (matched === null) {
matched = document.createElement(originalType);
}
let matched: HTMLElement | null = null;
if (vnode.key) {
matched = document.head.querySelector(
`head [data-key="${vnode.key}"]`,
) as HTMLElement ?? null;
}
if (matched.textContent !== text) {
matched.textContent = text;
}
if (matched === null && props.id) {
matched = document.head.querySelector(
`#${props.name}`,
) as HTMLElement ??
null;
}
applyProps(props, matched);
}, []);
if (matched === null) {
if (originalType === "meta") {
matched = document.head.querySelector(
`head [name="${props.name}"]`,
) as HTMLElement ?? null;
} else if (originalType === "base") {
matched = document.head.querySelector(originalType) ?? null;
}
}
return null;
};
if (matched === null) {
matched = document.createElement(originalType as string);
}
if (matched.textContent !== text) {
matched.textContent = text;
}
applyProps(props, matched);
}, []);
return null;
};
}
break;
}
}
+4
View File
@@ -152,6 +152,7 @@ Deno.test("Head - ssr - merge keyed", async () => {
});
Deno.test({
ignore: true, // Temporarily until client perf is fixed
name: "Head - client - set title",
fn: async () => {
const applyCache = await buildProd({
@@ -181,6 +182,7 @@ Deno.test({
});
Deno.test({
ignore: true, // Temporarily until client perf is fixed
name: "Head - client - match meta",
fn: async () => {
const applyCache = await buildProd({
@@ -225,6 +227,7 @@ Deno.test({
});
Deno.test({
ignore: true, // Temporarily until client perf is fixed
name: "Head - client - match style by id",
fn: async () => {
const applyCache = await buildProd({
@@ -269,6 +272,7 @@ Deno.test({
});
Deno.test({
ignore: true, // Temporarily until client perf is fixed
name: "Head - client - match key",
fn: async () => {
const applyCache = await buildProd({