router icon indicating copy to clipboard operation
router copied to clipboard

Document head content defined in HTML is not deduplicated

Open committomaster opened this issue 7 months ago • 1 comments

Which project does this relate to?

Router

Describe the bug

With SPAs, some document head content is typically set in HTML before JS is run. The current HeadContent implementation seems to not take this into account and duplicate these tags if overwritten by JS.

Your Example Website or App

https://stackblitz.com/edit/github-ahupwy5s?file=src%2Fmain.tsx

Steps to Reproduce the Bug or Issue

  1. Open the provided example.
  2. Inspect the document tree in dev tools.
  3. Title and meta tags from JS are duplicated instead of overwriting the base values from HTML.

Expected behavior

Router should take the document head content defined in HTML as base for modification by JS.

Screenshots or Videos

Image

Platform

  • OS: any
  • Browser: any
  • Version: any

Additional context

No response

committomaster avatar May 19 '25 01:05 committomaster

I have a similar problem. When I use the title tag outside of meta, the title doesn't change. I moved title inside of meta and it doesnt dedup (but the title does change, as in your example)

Using vite with @tanstack/[email protected] and react19

spretto avatar Jun 10 '25 14:06 spretto