diff --git a/packages/fresh/src/runtime/client/preact_hooks_client.ts b/packages/fresh/src/runtime/client/preact_hooks_client.ts index c1834df3..22bf351e 100644 --- a/packages/fresh/src/runtime/client/preact_hooks_client.ts +++ b/packages/fresh/src/runtime/client/preact_hooks_client.ts @@ -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; } } diff --git a/packages/fresh/tests/head_test.tsx b/packages/fresh/tests/head_test.tsx index 2fe1d53b..b43356e8 100644 --- a/packages/fresh/tests/head_test.tsx +++ b/packages/fresh/tests/head_test.tsx @@ -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({