refactor: remove marker comments on hydration (#110)

This commit is contained in:
Luca Casonato
2022-03-06 03:44:47 +01:00
committed by GitHub
parent bb7180328e
commit 72115506b1
+5
View File
@@ -34,11 +34,16 @@ export function revive(islands: Record<string, ComponentType>) {
const tag = node!.nodeType === 8 && const tag = node!.nodeType === 8 &&
((node as Comment).data.match(/^\s*frsh-(.*)\s*$/) || [])[1]; ((node as Comment).data.match(/^\s*frsh-(.*)\s*$/) || [])[1];
if (tag) { if (tag) {
const startNode = node!;
const children = []; const children = [];
const parent = node!.parentNode; const parent = node!.parentNode;
while ((node = node!.nextSibling) && node.nodeType !== 8) { while ((node = node!.nextSibling) && node.nodeType !== 8) {
children.push(node); children.push(node);
} }
startNode.parentNode!.removeChild(startNode);
if (node) {
node.parentNode?.removeChild(node);
}
const [id, n] = tag.split(":"); const [id, n] = tag.split(":");
render( render(
h(islands[id], ISLAND_PROPS[Number(n)]), h(islands[id], ISLAND_PROPS[Number(n)]),