Unverified Commit bdc53ef6 authored by Hannes Bornö's avatar Hannes Bornö Committed by GitHub

Root layout head not required (#41621)

Remove head as required in root layout.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
parent 001a67df
...@@ -14,7 +14,7 @@ export type RootLayoutErrorProps = { missingTags: string[] } ...@@ -14,7 +14,7 @@ export type RootLayoutErrorProps = { missingTags: string[] }
export const RootLayoutError: React.FC<RootLayoutErrorProps> = export const RootLayoutError: React.FC<RootLayoutErrorProps> =
function BuildError({ missingTags }) { function BuildError({ missingTags }) {
const message = const message =
'Please make sure to include the following tags in your root layout: <html>, <head>, <body>.\n\n' + 'Please make sure to include the following tags in your root layout: <html>, <body>.\n\n' +
`Missing required root layout tag${ `Missing required root layout tag${
missingTags.length === 1 ? '' : 's' missingTags.length === 1 ? '' : 's'
}: ` + }: ` +
......
...@@ -263,19 +263,15 @@ export function createRootLayoutValidatorStream( ...@@ -263,19 +263,15 @@ export function createRootLayoutValidatorStream(
getTree: () => FlightRouterState getTree: () => FlightRouterState
): TransformStream<Uint8Array, Uint8Array> { ): TransformStream<Uint8Array, Uint8Array> {
let foundHtml = false let foundHtml = false
let foundHead = false
let foundBody = false let foundBody = false
return new TransformStream({ return new TransformStream({
async transform(chunk, controller) { async transform(chunk, controller) {
if (!foundHtml || !foundHead || !foundBody) { if (!foundHtml || !foundBody) {
const content = decodeText(chunk) const content = decodeText(chunk)
if (!foundHtml && content.includes('<html')) { if (!foundHtml && content.includes('<html')) {
foundHtml = true foundHtml = true
} }
if (!foundHead && content.includes('<head')) {
foundHead = true
}
if (!foundBody && content.includes('<body')) { if (!foundBody && content.includes('<body')) {
foundBody = true foundBody = true
} }
...@@ -285,7 +281,6 @@ export function createRootLayoutValidatorStream( ...@@ -285,7 +281,6 @@ export function createRootLayoutValidatorStream(
flush(controller) { flush(controller) {
const missingTags = [ const missingTags = [
foundHtml ? null : 'html', foundHtml ? null : 'html',
foundHead ? null : 'head',
foundBody ? null : 'body', foundBody ? null : 'body',
].filter(nonNullable) ].filter(nonNullable)
......
...@@ -43,9 +43,9 @@ describe('app-dir root layout', () => { ...@@ -43,9 +43,9 @@ describe('app-dir root layout', () => {
expect(await hasRedbox(browser, true)).toBe(true) expect(await hasRedbox(browser, true)).toBe(true)
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(` expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
"Please make sure to include the following tags in your root layout: <html>, <head>, <body>. "Please make sure to include the following tags in your root layout: <html>, <body>.
Missing required root layout tags: html, head, body" Missing required root layout tags: html, body"
`) `)
}) })
...@@ -57,9 +57,9 @@ describe('app-dir root layout', () => { ...@@ -57,9 +57,9 @@ describe('app-dir root layout', () => {
expect(await hasRedbox(browser, true)).toBe(true) expect(await hasRedbox(browser, true)).toBe(true)
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(` expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
"Please make sure to include the following tags in your root layout: <html>, <head>, <body>. "Please make sure to include the following tags in your root layout: <html>, <body>.
Missing required root layout tags: html, head, body" Missing required root layout tags: html, body"
`) `)
}) })
...@@ -70,9 +70,9 @@ describe('app-dir root layout', () => { ...@@ -70,9 +70,9 @@ describe('app-dir root layout', () => {
expect(await hasRedbox(browser, true)).toBe(true) expect(await hasRedbox(browser, true)).toBe(true)
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(` expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
"Please make sure to include the following tags in your root layout: <html>, <head>, <body>. "Please make sure to include the following tags in your root layout: <html>, <body>.
Missing required root layout tags: html, head, body" Missing required root layout tags: html, body"
`) `)
}) })
}) })
......
...@@ -4,9 +4,6 @@ export const revalidate = 0 ...@@ -4,9 +4,6 @@ export const revalidate = 0
export default function Root({ children }) { export default function Root({ children }) {
return ( return (
<html> <html>
<head>
<title>Hello World</title>
</head>
<body>{children}</body> <body>{children}</body>
</html> </html>
) )
......
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