diff --git a/.changeset/silver-singers-tell.md b/.changeset/silver-singers-tell.md new file mode 100644 index 000000000000..c32da7bae205 --- /dev/null +++ b/.changeset/silver-singers-tell.md @@ -0,0 +1,8 @@ +--- +'astro': patch +--- + +Revives UnoCSS in dev mode when used with the client router. + +This change partly reverts [#16089](https://github.com/withastro/astro/pull/16089), which in hindsight turned out to be too general. Instead of automatically persisting all style sheets, we now do this only for styles from Vue components. + diff --git a/packages/astro/src/transitions/swap-functions.ts b/packages/astro/src/transitions/swap-functions.ts index 2f7e52bfcfc9..9fd49571970b 100644 --- a/packages/astro/src/transitions/swap-functions.ts +++ b/packages/astro/src/transitions/swap-functions.ts @@ -174,8 +174,7 @@ export const restoreFocus = ({ activeElement, start, end }: SavedFocus) => { }; // Check for a head element that should persist and returns it, -// either because it has the data attribute or is a link el. -// Returns null if the element is not part of the new head, undefined if it should be left alone. +// either because it has the data attribute or because replacing it would cause avoidable FOUC. const persistedHeadElement = (el: HTMLElement, newDoc: Document): Element | null => { const id = el.getAttribute(PERSIST_ATTR); const newEl = id && newDoc.head.querySelector(`[${PERSIST_ATTR}="${id}"]`); @@ -187,12 +186,16 @@ const persistedHeadElement = (el: HTMLElement, newDoc: Document): Element | null return newDoc.head.querySelector(`link[rel=stylesheet][href="${href}"]`); } // In dev mode, Vite injects