Unverified Commit 58755e6d authored by Furkan MT's avatar Furkan MT Committed by GitHub

fixes #31060: NullReferenceException (#31061)

* fix(#31060): NullReferenceException

Related Issue: https://github.com/vercel/next.js/issues/31060

* Type 'undefined' is not assignable to type 'Element | null'
Co-authored-by: 's avatarSteven <steven@ceriously.com>
parent 913adb8e
......@@ -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(
......@@ -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()
}
......
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