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

Function getHostSibling

code/dependency-injection/public/app.js:11709–11748  ·  view source on GitHub ↗
(fiber)

Source from the content-addressed store, hash-verified

11707 }
11708
11709 function getHostSibling(fiber) {
11710 // We're going to search forward into the tree until we find a sibling host
11711 // node. Unfortunately, if multiple insertions are done in a row we have to
11712 // search past them. This leads to exponential search for the next sibling.
11713 var node = fiber;
11714 siblings: while (true) {
11715 // If we didn't find anything, let's try the next sibling.
11716 while (node.sibling === null) {
11717 if (node['return'] === null || isHostParent(node['return'])) {
11718 // If we pop out of the root or hit the parent the fiber we are the
11719 // last sibling.
11720 return null;
11721 }
11722 node = node['return'];
11723 }
11724 node.sibling['return'] = node['return'];
11725 node = node.sibling;
11726 while (node.tag !== HostComponent && node.tag !== HostText) {
11727 // If it is not host node and, we might have a host node inside it.
11728 // Try to search down until we find one.
11729 if (node.effectTag & Placement) {
11730 // If we don't have a child, try the siblings instead.
11731 continue siblings;
11732 }
11733 // If we don't have a child, try the siblings instead.
11734 // We also skip portals because they are not part of this host tree.
11735 if (node.child === null || node.tag === HostPortal) {
11736 continue siblings;
11737 } else {
11738 node.child['return'] = node;
11739 node = node.child;
11740 }
11741 }
11742 // Check if this host node is stable or about to be placed.
11743 if (!(node.effectTag & Placement)) {
11744 // Found it!
11745 return node.stateNode;
11746 }
11747 }
11748 }
11749
11750 function commitPlacement(finishedWork) {
11751 // Recursively insert all host nodes into the parent.

Callers 1

commitPlacementFunction · 0.70

Calls 1

isHostParentFunction · 0.70

Tested by

no test coverage detected