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

Function commitPlacement

code/third-party/public/app.js:10890–10958  ·  view source on GitHub ↗
(finishedWork)

Source from the content-addressed store, hash-verified

10888 }
10889
10890 function commitPlacement(finishedWork) {
10891 // Recursively insert all host nodes into the parent.
10892 var parentFiber = getHostParentFiber(finishedWork);
10893 var parent = void 0;
10894 var isContainer = void 0;
10895 switch (parentFiber.tag) {
10896 case HostComponent:
10897 parent = parentFiber.stateNode;
10898 isContainer = false;
10899 break;
10900 case HostRoot:
10901 parent = parentFiber.stateNode.containerInfo;
10902 isContainer = true;
10903 break;
10904 case HostPortal:
10905 parent = parentFiber.stateNode.containerInfo;
10906 isContainer = true;
10907 break;
10908 default:
10909 invariant(false, 'Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue.');
10910 }
10911 if (parentFiber.effectTag & ContentReset) {
10912 // Reset the text content of the parent before doing any insertions
10913 resetTextContent(parent);
10914 // Clear ContentReset from the effect tag
10915 parentFiber.effectTag &= ~ContentReset;
10916 }
10917
10918 var before = getHostSibling(finishedWork);
10919 // We only have the top Fiber that was inserted but we need recurse down its
10920 // children to find all the terminal nodes.
10921 var node = finishedWork;
10922 while (true) {
10923 if (node.tag === HostComponent || node.tag === HostText) {
10924 if (before) {
10925 if (isContainer) {
10926 insertInContainerBefore(parent, node.stateNode, before);
10927 } else {
10928 insertBefore(parent, node.stateNode, before);
10929 }
10930 } else {
10931 if (isContainer) {
10932 appendChildToContainer(parent, node.stateNode);
10933 } else {
10934 appendChild(parent, node.stateNode);
10935 }
10936 }
10937 } else if (node.tag === HostPortal) {
10938 // If the insertion itself is a portal, then we don't want to traverse
10939 // down its children. Instead, we'll get insertions from each child in
10940 // the portal directly.
10941 } else if (node.child !== null) {
10942 node.child['return'] = node;
10943 node = node.child;
10944 continue;
10945 }
10946 if (node === finishedWork) {
10947 return;

Callers 1

commitAllHostEffectsFunction · 0.70

Calls 3

getHostParentFiberFunction · 0.70
invariantFunction · 0.70
getHostSiblingFunction · 0.70

Tested by

no test coverage detected