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

Function getHostSibling

code/composition/public/app.js:11754–11793  ·  view source on GitHub ↗
(fiber)

Source from the content-addressed store, hash-verified

11752 }
11753
11754 function getHostSibling(fiber) {
11755 // We're going to search forward into the tree until we find a sibling host
11756 // node. Unfortunately, if multiple insertions are done in a row we have to
11757 // search past them. This leads to exponential search for the next sibling.
11758 var node = fiber;
11759 siblings: while (true) {
11760 // If we didn't find anything, let's try the next sibling.
11761 while (node.sibling === null) {
11762 if (node['return'] === null || isHostParent(node['return'])) {
11763 // If we pop out of the root or hit the parent the fiber we are the
11764 // last sibling.
11765 return null;
11766 }
11767 node = node['return'];
11768 }
11769 node.sibling['return'] = node['return'];
11770 node = node.sibling;
11771 while (node.tag !== HostComponent && node.tag !== HostText) {
11772 // If it is not host node and, we might have a host node inside it.
11773 // Try to search down until we find one.
11774 if (node.effectTag & Placement) {
11775 // If we don't have a child, try the siblings instead.
11776 continue siblings;
11777 }
11778 // If we don't have a child, try the siblings instead.
11779 // We also skip portals because they are not part of this host tree.
11780 if (node.child === null || node.tag === HostPortal) {
11781 continue siblings;
11782 } else {
11783 node.child['return'] = node;
11784 node = node.child;
11785 }
11786 }
11787 // Check if this host node is stable or about to be placed.
11788 if (!(node.effectTag & Placement)) {
11789 // Found it!
11790 return node.stateNode;
11791 }
11792 }
11793 }
11794
11795 function commitPlacement(finishedWork) {
11796 // Recursively insert all host nodes into the parent.

Callers 1

commitPlacementFunction · 0.70

Calls 1

isHostParentFunction · 0.70

Tested by

no test coverage detected