Skip to content

fix: render root tag attributes without a document element on react 19 - #3

Merged
MatthewPattell merged 1 commit into
prodfrom
bugfix/react-19-root-tags
Sep 5, 2026
Merged

fix: render root tag attributes without a document element on react 19#3
MatthewPattell merged 1 commit into
prodfrom
bugfix/react-19-root-tags

Conversation

@MatthewPattell

Copy link
Copy Markdown
Contributor

Goal

MetaServer.inject emits <html lang="en"><head></head> before the populated head when the host application runs React 19: React 19 renders a full document for a root html element, and the opening-tag extraction relied on React 18 output. Observed on https://vite-template.lomray.com/ (React 19.2.8).

Changes

  • src/server/index.ts: serialize the merged root props on a div with renderToStaticMarkup, rename the opening tag to html or body, drop the closing tag. Output for the same props is identical to what React 18 produced before.
  • __tests__/server/index.tsx: regression cases for a single head, merged input and manager attributes on html and body, metadata placement, escaping, style objects and boolean attributes.
  • .github/workflows/pr-check.yml: run the tests on the lockfile stack (React 18) and again after swapping in react@19.2.8 and react-dom@19.2.8.

No public API change, no dependency change.

Verification

  • npm ci --ignore-scripts, npm run lint:check, npm run ts:check: clean.
  • npm test on React 18.2.0: 8 tests pass. After npm install --no-save --ignore-scripts react@19.2.8 react-dom@19.2.8: 8 tests pass.
  • npm run build on Node 20.18.3 (the repository's Node 20 line; the current Rollup plugin stack does not load on Node 22), packed lib, installed the archive into a copy of vite-template prod (React 19.2.8), ssr-boost build + ssr-boost start: / and /details each contain exactly one <head> and start with <html lang="en">\n <head><meta charSet="UTF-8"/>....
  • A fresh npm install react@19.2.8 react-dom@19.2.8 @lomray/react-head-manager@2.1.1 resolves without peer errors.

Not run

  • Browser rendering of the fixed markup (parsing of the previous output was already tolerated by browsers; the fix matters for crawlers and validators).

@sonarqubecloud

sonarqubecloud Bot commented Sep 5, 2026

Copy link
Copy Markdown

@MatthewPattell MatthewPattell self-assigned this Sep 5, 2026
@MatthewPattell MatthewPattell added the bug Something isn't working label Sep 5, 2026
@sonarqubecloud

sonarqubecloud Bot commented Sep 5, 2026

Copy link
Copy Markdown

@MatthewPattell
MatthewPattell merged commit 62948d6 into prod Sep 5, 2026
5 checks passed
@MatthewPattell
MatthewPattell deleted the bugfix/react-19-root-tags branch September 5, 2026 08:30
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 2.1.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

bug Something isn't working released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant