diff --git a/src/runtime/internal/dom.ts b/src/runtime/internal/dom.ts index e289d7e0a4..c325689c3a 100644 --- a/src/runtime/internal/dom.ts +++ b/src/runtime/internal/dom.ts @@ -36,9 +36,21 @@ function init_hydrate(target: NodeEx) { target.hydrate_init = true; type NodeEx2 = NodeEx & {claim_order: number}; - - // We know that all children have claim_order values since the unclaimed have been detached - const children = Array.from(target.childNodes as NodeListOf).filter(x => x.claim_order !== undefined) as NodeEx2[]; + + // We know that all children have claim_order values since the unclaimed have been detached if target is not head + let children: ArrayLike = target.childNodes as NodeListOf; + + // If target is head, there may be children without claim_order + if (target.nodeName.toLowerCase() == "head") { + const myChildren = []; + for (let i = 0; i < children.length; i++) { + const node = children[i]; + if (node.claim_order !== undefined) { + myChildren.push(node) + } + } + children = myChildren; + } /* * Reorder claimed children optimally.