Skip to content

fix: keep svg <title> from taking the <head> title - #3919

Open
1AbdullahButt wants to merge 1 commit into
freshframework:mainfrom
1AbdullahButt:fix/3916-svg-title
Open

1AbdullahButt wants to merge 1 commit into
freshframework:mainfrom
1AbdullahButt:fix/3916-svg-title

Conversation

@1AbdullahButt

Copy link
Copy Markdown

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 does head.

What changed

RenderState gets an insideHtmlHead flag. 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

  • New test in 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 that head > title is the page title and svg > title keeps its own text. It fails without this change (the svg title becomes the page title) and passes with it.
  • head_test.tsx and partials_test.tsx run in a Linux container with CI=1: 81 passed, 0 failed.
  • deno fmt --check, deno lint and deno check pass.

This change was written with Claude Code (an AI coding assistant).

🤖 Generated with Claude Code

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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tab title doesn't update to <Head> <title> when navigating to a page with another <title>

1 participant