fix: island rendered outside of bounding markers (#1495)

This commit is contained in:
Marvin Hagemeister
2023-07-21 17:05:05 +02:00
committed by GitHub
parent 3ab35a44f9
commit 5d07e6e9eb
9 changed files with 130 additions and 29 deletions
+10 -3
View File
@@ -21,8 +21,8 @@ function createRootFragment(
parentNode: parent,
firstChild: replaceNode[0],
childNodes: replaceNode,
insertBefore(node: Node, child: Node) {
parent.insertBefore(node, child);
insertBefore(node: Node, child: Node | null) {
parent.insertBefore(node, child ?? endMarker);
},
appendChild(child: Node) {
// We cannot blindly call `.append()` as that would add
@@ -305,7 +305,14 @@ function _walkInner(
_walkInner(islands, props, markerStack, vnodeStack, sib.firstChild);
}
if (marker !== null && marker.kind === MarkerKind.Slot) {
// Pop vnode if current marker is a slot or we are an island marker
// that was created inside another island
if (
marker !== null &&
(marker.kind === MarkerKind.Slot ||
markerStack.length > 1 &&
markerStack[markerStack.length - 2].kind === MarkerKind.Island)
) {
vnodeStack.pop();
}
}