-
Notifications
You must be signed in to change notification settings - Fork 29.1k
Closed
Labels
Font (next/font)Related to Next.js Font Optimization.Related to Next.js Font Optimization.
Description
What version of Next.js are you using?
12.0.4
What version of Node.js are you using?
12.22.3
What browser are you using?
Chrome
What operating system are you using?
macOS
How are you deploying your application?
next start
Describe the Bug
When a child element or fragment of the Head
component contains a falsely value in its children then the following build/runtime error will surface,"TypeError: Cannot read property 'type' of null"
. This error can surface at runtime or at build time depending on the build method being used. The SWC build system will surface the error at build time while the legacy build methodology will result in a runtime error.
Expected Behavior
Falsey child elements of elements contained within the Head
component should not result in a build/runtime error.
To Reproduce
- Place the following snippet of code in your
_document.js
.
<Head>
<>
{/* falsy child elements are not removed. This will result in 'null' when makeStylesheetInert is called recursively. */}
{null}
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin />
<link href="https://fonts.googleapis.com/css2?family=Open+Sans&display=swap" rel="stylesheet" />
</>
</Head>
- Run
yarn build
.
*Note: If you are using SWC the error will surface on step here. - Run
yarn start
. - Visit any page.
Please see the following repo for reproduction.
Metadata
Metadata
Assignees
Labels
Font (next/font)Related to Next.js Font Optimization.Related to Next.js Font Optimization.