Skip to content

Comments

[pull] main from withastro:main#395

Merged
pull[bot] merged 1 commit intocode:mainfrom
withastro:main
Feb 22, 2026
Merged

[pull] main from withastro:main#395
pull[bot] merged 1 commit intocode:mainfrom
withastro:main

Conversation

@pull
Copy link

@pull pull bot commented Feb 22, 2026

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

…d swap (#15514)

* fix: preserve inline styles and font preloads during ClientRouter head swap

During client-side navigation with ClientRouter, swapHeadElements() only
preserved elements with data-astro-transition-persist and stylesheet links.
Inline <style> tags (including @font-face declarations from <Font>) were
removed and re-appended on every navigation, forcing the browser to
re-evaluate them and triggering a visible font flash (FOUT).

This extends persistedHeadElement() to also match:
- Inline <style> elements by their text content
- Font preload links (link[rel=preload][as=font]) by href

When an identical element exists in both the old and new document head,
it stays in the DOM instead of being removed and re-inserted.

Fixes #15465

* add changeset

* Add e2e test for inline style and font preload persistence

Add a test that verifies inline <style> elements (e.g. @font-face
declarations) and font preload links survive head swaps during
client-side navigation, preventing FOUT (Flash of Unstyled Text).

The test navigates between two pages sharing identical inline styles
and font preloads, and asserts that the original DOM nodes persist
rather than being removed and re-inserted.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: resolve lint errors and flaky e2e test for font persistence

Remove unused variables (styleIdBefore, preloadIdBefore) to fix biome
lint errors. Replace fragile exact style count comparison with
greaterThan(0) checks, since Astro may inject additional style elements
during client-side navigation. Use data-attribute selectors to directly
query the marked DOM nodes instead of relying on querySelector order.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Make the test a bit more concise

* Update fix-font-head-swap.md

---------

Co-authored-by: Martin Trapp <94928215+martrapp@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@pull pull bot locked and limited conversation to collaborators Feb 22, 2026
@pull pull bot added the ⤵️ pull label Feb 22, 2026
@pull pull bot merged commit 999a7dd into code:main Feb 22, 2026
7 of 11 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant