Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 : )