From 0a19fad29c15cb7a3c08e7ac640830d658f1644f Mon Sep 17 00:00:00 2001 From: Sebastian Markbage Date: Thu, 27 Jun 2024 21:06:01 -0400 Subject: [PATCH] Prefix html tags with doctype --- packages/react-html/src/ReactFizzConfigHTML.js | 5 +---- .../react-html/src/__tests__/ReactHTMLClient-test.js | 11 +++++++++++ .../react-html/src/__tests__/ReactHTMLServer-test.js | 11 +++++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/packages/react-html/src/ReactFizzConfigHTML.js b/packages/react-html/src/ReactFizzConfigHTML.js index 81528b0cdb81c..712938a5eb493 100644 --- a/packages/react-html/src/ReactFizzConfigHTML.js +++ b/packages/react-html/src/ReactFizzConfigHTML.js @@ -41,10 +41,6 @@ import { stringToPrecomputedChunk, } from 'react-server/src/ReactServerStreamConfig'; -// this chunk is empty on purpose because we do not want to emit the DOCTYPE -// when markup is rendering HTML -export const doctypeChunk: PrecomputedChunk = stringToPrecomputedChunk(''); - export type { RenderState, ResumableState, @@ -81,6 +77,7 @@ export { resetResumableState, completeResumableState, emitEarlyPreloads, + doctypeChunk, } from 'react-dom-bindings/src/server/ReactFizzConfigDOM'; import escapeTextForBrowser from 'react-dom-bindings/src/server/escapeTextForBrowser'; diff --git a/packages/react-html/src/__tests__/ReactHTMLClient-test.js b/packages/react-html/src/__tests__/ReactHTMLClient-test.js index 4f052288a8403..36a44ebc6d21a 100644 --- a/packages/react-html/src/__tests__/ReactHTMLClient-test.js +++ b/packages/react-html/src/__tests__/ReactHTMLClient-test.js @@ -28,6 +28,17 @@ describe('ReactHTML', () => { expect(html).toBe('
hello world
'); }); + it('should prefix html tags with a doctype', async () => { + const html = await ReactHTML.renderToMarkup( + + hello + , + ); + expect(html).toBe( + 'hello', + ); + }); + it('should error on useState', async () => { function Component() { const [state] = React.useState('hello'); diff --git a/packages/react-html/src/__tests__/ReactHTMLServer-test.js b/packages/react-html/src/__tests__/ReactHTMLServer-test.js index ecb33c1c040d3..0a758631b3643 100644 --- a/packages/react-html/src/__tests__/ReactHTMLServer-test.js +++ b/packages/react-html/src/__tests__/ReactHTMLServer-test.js @@ -38,6 +38,17 @@ describe('ReactHTML', () => { expect(html).toBe('
hello world
'); }); + it('should prefix html tags with a doctype', async () => { + const html = await ReactHTML.renderToMarkup( + + hello + , + ); + expect(html).toBe( + 'hello', + ); + }); + it('should error on useState', async () => { function Component() { const [state] = React.useState('hello');