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

Function commitPlacement

code/communication/public/app.js:11692–11760  ·  view source on GitHub ↗
(finishedWork)

Source from the content-addressed store, hash-verified

11690 }
11691
11692 function commitPlacement(finishedWork) {
11693 // Recursively insert all host nodes into the parent.
11694 var parentFiber = getHostParentFiber(finishedWork);
11695 var parent = void 0;
11696 var isContainer = void 0;
11697 switch (parentFiber.tag) {
11698 case HostComponent:
11699 parent = parentFiber.stateNode;
11700 isContainer = false;
11701 break;
11702 case HostRoot:
11703 parent = parentFiber.stateNode.containerInfo;
11704 isContainer = true;
11705 break;
11706 case HostPortal:
11707 parent = parentFiber.stateNode.containerInfo;
11708 isContainer = true;
11709 break;
11710 default:
11711 invariant(false, 'Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue.');
11712 }
11713 if (parentFiber.effectTag & ContentReset) {
11714 // Reset the text content of the parent before doing any insertions
11715 resetTextContent(parent);
11716 // Clear ContentReset from the effect tag
11717 parentFiber.effectTag &= ~ContentReset;
11718 }
11719
11720 var before = getHostSibling(finishedWork);
11721 // We only have the top Fiber that was inserted but we need recurse down its
11722 // children to find all the terminal nodes.
11723 var node = finishedWork;
11724 while (true) {
11725 if (node.tag === HostComponent || node.tag === HostText) {
11726 if (before) {
11727 if (isContainer) {
11728 insertInContainerBefore(parent, node.stateNode, before);
11729 } else {
11730 insertBefore(parent, node.stateNode, before);
11731 }
11732 } else {
11733 if (isContainer) {
11734 appendChildToContainer(parent, node.stateNode);
11735 } else {
11736 appendChild(parent, node.stateNode);
11737 }
11738 }
11739 } else if (node.tag === HostPortal) {
11740 // If the insertion itself is a portal, then we don't want to traverse
11741 // down its children. Instead, we'll get insertions from each child in
11742 // the portal directly.
11743 } else if (node.child !== null) {
11744 node.child['return'] = node;
11745 node = node.child;
11746 continue;
11747 }
11748 if (node === finishedWork) {
11749 return;

Callers 1

commitAllHostEffectsFunction · 0.70

Calls 3

getHostParentFiberFunction · 0.70
invariantFunction · 0.70
getHostSiblingFunction · 0.70

Tested by

no test coverage detected