Skip to content

Commit

Permalink
fixes vercel#31060: NullReferenceException (vercel#31061)
Browse files Browse the repository at this point in the history
* fix(vercel#31060): NullReferenceException

Related Issue: vercel#31060

* Type 'undefined' is not assignable to type 'Element | null'

Co-authored-by: Steven <[email protected]>
  • Loading branch information
furcan and styfle authored Nov 8, 2021
1 parent 913adb8 commit 58755e6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/next/client/head-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ function updateElements(type: string, components: JSX.Element[]): void {
for (
let i = 0, j = headCountEl.previousElementSibling;
i < headCount;
i++, j = j!.previousElementSibling
i++, j = j?.previousElementSibling || null
) {
if (j?.tagName?.toLowerCase() === type) {
oldTags.push(j!)
oldTags.push(j)
}
}
const newTags = (components.map(reactElementToDOM) as HTMLElement[]).filter(
Expand All @@ -79,7 +79,7 @@ function updateElements(type: string, components: JSX.Element[]): void {
}
)

oldTags.forEach((t) => t.parentNode!.removeChild(t))
oldTags.forEach((t) => t.parentNode?.removeChild(t))
newTags.forEach((t) => headEl.insertBefore(t, headCountEl))
headCountEl.content = (headCount - oldTags.length + newTags.length).toString()
}
Expand Down

0 comments on commit 58755e6

Please sign in to comment.