fix: stylesheet links in <Head> drop entry CSS (#3825)

The Head cache key for <link> excluded href for every rel, so any <link
rel="stylesheet"> in <Head> collided with entry-asset stylesheets (e.g.
Tailwind) and replaced them at the layout's <head> position. The href
exclusion was added to let <Head> override a singleton like canonical
without a key; scope it to those rels so distinct stylesheets no longer
dedupe.

Closes #3824
This commit is contained in:
Leo Kettmeir
2026-05-27 15:10:31 +02:00
committed by GitHub
parent 3afaaf4f78
commit 56faed1998
2 changed files with 47 additions and 1 deletions
@@ -203,6 +203,14 @@ options[OptionsType.ATTR] = (name, value) => {
const PATCHED = new WeakSet<VNode>();
// Link rels whose presence is conceptually singleton: a `<Head>` override
// should replace the existing tag regardless of its href. Other rels
// (stylesheet, preload, alternate, ...) can legitimately appear multiple
// times with different hrefs, so href must remain part of the cache key.
function isSingletonLinkRel(rel: unknown): boolean {
return rel === "canonical" || rel === "manifest";
}
function normalizeKey(key: unknown): string {
const value = key ?? "";
const s = (typeof value !== "string") ? String(value) : value;
@@ -406,7 +414,10 @@ options[OptionsType.DIFF] = (vnode) => {
continue;
} else if (originalType === "meta" && key === "content") {
continue;
} else if (originalType === "link" && key === "href") {
} else if (
originalType === "link" && key === "href" &&
isSingletonLinkRel(props.rel)
) {
continue;
}