Skip to content

Commit

Permalink
fix(runtime): hydrate shadow dom first
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-bromann committed Jul 25, 2024
1 parent 7ae36aa commit be06d5c
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/runtime/client-hydrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,6 @@ const clientHydrate = (
}
}

// recursively drill down, end to start so we can remove nodes
for (i = node.childNodes.length - 1; i >= 0; i--) {
clientHydrate(
parentVNode,
childRenderNodes,
slotNodes,
shadowRootNodes,
hostElm,
node.childNodes[i] as any,
hostId,
);
}

if (node.shadowRoot) {
// keep drilling down through the shadow root nodes
for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
Expand All @@ -181,6 +168,20 @@ const clientHydrate = (
);
}
}

// recursively drill down, end to start so we can remove nodes
for (i = node.childNodes.length - 1; i >= 0; i--) {
clientHydrate(
parentVNode,
childRenderNodes,
slotNodes,
shadowRootNodes,
hostElm,
node.childNodes[i] as any,
hostId,
);
}

} else if (node.nodeType === NODE_TYPE.CommentNode) {
// `${COMMENT_TYPE}.${hostId}.${nodeId}.${depth}.${index}`
childIdSplt = node.nodeValue.split('.');
Expand Down

0 comments on commit be06d5c

Please sign in to comment.