Repository navigation
fix: keep svg <title> from taking the <head> title - #3919
Open
1AbdullahButt wants to merge 1 commit into
Open
1AbdullahButt wants to merge 1 commit into
1AbdullahButt wants to merge 1 commit into
Conversation
A <title> rendered outside <Head>, like the one inside an <svg>, picked up the cached <Head> title during SSR. The page's <head> then kept its fallback title, so the tab title did not change on navigation. Only replace head elements while the document's <head> is being rendered. Fixes freshframework#3916 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #3916
What was wrong
When a page sets a title with
<Head><title>…</title></Head>, SSR remembers it and replaces the next<title>it renders. The check didn't look at where that<title>was. A<title>inside an inline<svg>(used for accessible icon labels) could be swapped for the page title, so the icon's label became the page title.Because of
jsx: "precompile", static markup like<svg>is compiled into template strings and has no vnode, so the hook can't tell from a parent vnode that it's inside an SVG. Head elements stay vnodes (jsxPrecompileSkipElements), and so doeshead.What changed
RenderStategets aninsideHtmlHeadflag. It is set when the<head>vnode is diffed and cleared when that vnode finishes. Head elements are only replaced with the cached<Head>value while the flag is set. Outside<head>they render as written.Tests
packages/fresh/tests/head_test.tsx: "Head - ssr - keeps svg<title>out of<head>". It renders a<Head>title plus an svg with its own<title>. It checks thathead > titleis the page title andsvg > titlekeeps its own text. It fails without this change (the svg title becomes the page title) and passes with it.head_test.tsxandpartials_test.tsxrun in a Linux container withCI=1: 81 passed, 0 failed.deno fmt --check,deno lintanddeno checkpass.This change was written with Claude Code (an AI coding assistant).
🤖 Generated with Claude Code