Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #31060: NullReferenceException #31061

Merged
merged 4 commits into from Nov 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/next/client/head-manager.ts
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
styfle marked this conversation as resolved.
Show resolved Hide resolved
) {
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