MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / getHostSibling

Function getHostSibling

code/styling/public/app.js:11616–11655  ·  view source on GitHub ↗
(fiber)

Source from the content-addressed store, hash-verified

11614 }
11615
11616 function getHostSibling(fiber) {
11617 // We're going to search forward into the tree until we find a sibling host
11618 // node. Unfortunately, if multiple insertions are done in a row we have to
11619 // search past them. This leads to exponential search for the next sibling.
11620 var node = fiber;
11621 siblings: while (true) {
11622 // If we didn't find anything, let's try the next sibling.
11623 while (node.sibling === null) {
11624 if (node['return'] === null || isHostParent(node['return'])) {
11625 // If we pop out of the root or hit the parent the fiber we are the
11626 // last sibling.
11627 return null;
11628 }
11629 node = node['return'];
11630 }
11631 node.sibling['return'] = node['return'];
11632 node = node.sibling;
11633 while (node.tag !== HostComponent && node.tag !== HostText) {
11634 // If it is not host node and, we might have a host node inside it.
11635 // Try to search down until we find one.
11636 if (node.effectTag & Placement) {
11637 // If we don't have a child, try the siblings instead.
11638 continue siblings;
11639 }
11640 // If we don't have a child, try the siblings instead.
11641 // We also skip portals because they are not part of this host tree.
11642 if (node.child === null || node.tag === HostPortal) {
11643 continue siblings;
11644 } else {
11645 node.child['return'] = node;
11646 node = node.child;
11647 }
11648 }
11649 // Check if this host node is stable or about to be placed.
11650 if (!(node.effectTag & Placement)) {
11651 // Found it!
11652 return node.stateNode;
11653 }
11654 }
11655 }
11656
11657 function commitPlacement(finishedWork) {
11658 // Recursively insert all host nodes into the parent.

Callers 1

commitPlacementFunction · 0.70

Calls 1

isHostParentFunction · 0.70

Tested by

no test coverage detected