Unverified Commit 3a17d4d2 authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

fix: bad script tag in layout hydration error (#66998)

parent fc382a91
...@@ -17,7 +17,6 @@ export const hydrationErrorState: HydrationErrorState = {} ...@@ -17,7 +17,6 @@ export const hydrationErrorState: HydrationErrorState = {}
// https://github.com/facebook/react/blob/main/packages/react-dom/src/__tests__/ReactDOMHydrationDiff-test.js used as a reference // https://github.com/facebook/react/blob/main/packages/react-dom/src/__tests__/ReactDOMHydrationDiff-test.js used as a reference
const htmlTagsWarnings = new Set([ const htmlTagsWarnings = new Set([
'Warning: Cannot render a sync or defer <script> outside the main document without knowing its order. Try adding async="" or moving it into the root <head> tag.%s',
'Warning: In HTML, %s cannot be a child of <%s>.%s\nThis will cause a hydration error.%s', 'Warning: In HTML, %s cannot be a child of <%s>.%s\nThis will cause a hydration error.%s',
'Warning: In HTML, %s cannot be a descendant of <%s>.\nThis will cause a hydration error.%s', 'Warning: In HTML, %s cannot be a descendant of <%s>.\nThis will cause a hydration error.%s',
'Warning: In HTML, text nodes cannot be a child of <%s>.\nThis will cause a hydration error.', 'Warning: In HTML, text nodes cannot be a child of <%s>.\nThis will cause a hydration error.',
......
...@@ -720,16 +720,28 @@ describe('Error overlay for hydration errors', () => { ...@@ -720,16 +720,28 @@ describe('Error overlay for hydration errors', () => {
expect(await getRedboxTotalErrorCount(browser)).toBe(1) expect(await getRedboxTotalErrorCount(browser)).toBe(1)
const description = await session.getRedboxDescription() const description = await session.getRedboxDescription()
// FIXME expect(description).toEqual(outdent`
expect(description).toContain( In HTML, <script> cannot be a child of <html>.
"TypeError: Cannot read properties of undefined (reading 'replace')" This will cause a hydration error.
) `)
// const pseudoHtml = await session.getRedboxComponentStack() const pseudoHtml = await session.getRedboxComponentStack()
// expect(pseudoHtml).toEqual(outdent` if (isTurbopack) {
// <script> expect(pseudoHtml).toEqual(outdent`
// ^^^^^^^^ ...
// `) <Layout>
<html>
^^^^^^
<Script>
<script>
^^^^^^^^
`)
} else {
expect(pseudoHtml).toEqual(outdent`
<script>
^^^^^^^^
`)
}
await cleanup() await cleanup()
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment