From 589fb81f6db27a9a8b7ff8df0cf42f54fcfb0c9c Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Tue, 6 Dec 2022 12:57:04 +0100 Subject: [PATCH] Revert "Adding head element checking for root layout (#43597)" This reverts commit 482fccb92234bb017cdc0d376724d678aa306e53. --- .../internal/container/RootLayoutError.tsx | 2 +- packages/next/server/node-web-streams-helper.ts | 7 +------ test/e2e/app-dir/root-layout.test.ts | 12 ++++++------ .../app/(required-tags)/has-tags/layout.js | 3 --- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/packages/next/client/components/react-dev-overlay/internal/container/RootLayoutError.tsx b/packages/next/client/components/react-dev-overlay/internal/container/RootLayoutError.tsx index 5e68fb856175e..e9d9648b87f67 100644 --- a/packages/next/client/components/react-dev-overlay/internal/container/RootLayoutError.tsx +++ b/packages/next/client/components/react-dev-overlay/internal/container/RootLayoutError.tsx @@ -14,7 +14,7 @@ export type RootLayoutErrorProps = { missingTags: string[] } export const RootLayoutError: React.FC = function BuildError({ missingTags }) { const message = - 'Please make sure to include the following tags in your root layout: , , .\n\n' + + 'Please make sure to include the following tags in your root layout: , .\n\n' + `Missing required root layout tag${ missingTags.length === 1 ? '' : 's' }: ` + diff --git a/packages/next/server/node-web-streams-helper.ts b/packages/next/server/node-web-streams-helper.ts index a2062a66778f2..c82ff473824f2 100644 --- a/packages/next/server/node-web-streams-helper.ts +++ b/packages/next/server/node-web-streams-helper.ts @@ -288,19 +288,15 @@ export function createRootLayoutValidatorStream( getTree: () => FlightRouterState ): TransformStream { let foundHtml = false - let foundHead = false let foundBody = false return new TransformStream({ async transform(chunk, controller) { - if (!foundHtml || !foundHead || !foundBody) { + if (!foundHtml || !foundBody) { const content = decodeText(chunk) if (!foundHtml && content.includes(' { expect(await hasRedbox(browser, true)).toBe(true) expect(await getRedboxSource(browser)).toMatchInlineSnapshot(` - "Please make sure to include the following tags in your root layout: , , . + "Please make sure to include the following tags in your root layout: , . - Missing required root layout tags: html, head, body" + Missing required root layout tags: html, body" `) }) @@ -54,9 +54,9 @@ describe('app-dir root layout', () => { expect(await hasRedbox(browser, true)).toBe(true) expect(await getRedboxSource(browser)).toMatchInlineSnapshot(` - "Please make sure to include the following tags in your root layout: , , . + "Please make sure to include the following tags in your root layout: , . - Missing required root layout tags: html, head, body" + Missing required root layout tags: html, body" `) }) @@ -67,9 +67,9 @@ describe('app-dir root layout', () => { expect(await hasRedbox(browser, true)).toBe(true) expect(await getRedboxSource(browser)).toMatchInlineSnapshot(` - "Please make sure to include the following tags in your root layout: , , . + "Please make sure to include the following tags in your root layout: , . - Missing required root layout tags: html, head, body" + Missing required root layout tags: html, body" `) }) }) diff --git a/test/e2e/app-dir/root-layout/app/(required-tags)/has-tags/layout.js b/test/e2e/app-dir/root-layout/app/(required-tags)/has-tags/layout.js index f8fd9c6d9b3ea..7519206f5c7b3 100644 --- a/test/e2e/app-dir/root-layout/app/(required-tags)/has-tags/layout.js +++ b/test/e2e/app-dir/root-layout/app/(required-tags)/has-tags/layout.js @@ -4,9 +4,6 @@ export const revalidate = 0 export default function Root({ children }) { return ( - - Hello World - {children} )