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

Function commitPlacement

code/higher-order-components/public/app.js:11651–11719  ·  view source on GitHub ↗
(finishedWork)

Source from the content-addressed store, hash-verified

11649 }
11650
11651 function commitPlacement(finishedWork) {
11652 // Recursively insert all host nodes into the parent.
11653 var parentFiber = getHostParentFiber(finishedWork);
11654 var parent = void 0;
11655 var isContainer = void 0;
11656 switch (parentFiber.tag) {
11657 case HostComponent:
11658 parent = parentFiber.stateNode;
11659 isContainer = false;
11660 break;
11661 case HostRoot:
11662 parent = parentFiber.stateNode.containerInfo;
11663 isContainer = true;
11664 break;
11665 case HostPortal:
11666 parent = parentFiber.stateNode.containerInfo;
11667 isContainer = true;
11668 break;
11669 default:
11670 invariant(false, 'Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue.');
11671 }
11672 if (parentFiber.effectTag & ContentReset) {
11673 // Reset the text content of the parent before doing any insertions
11674 resetTextContent(parent);
11675 // Clear ContentReset from the effect tag
11676 parentFiber.effectTag &= ~ContentReset;
11677 }
11678
11679 var before = getHostSibling(finishedWork);
11680 // We only have the top Fiber that was inserted but we need recurse down its
11681 // children to find all the terminal nodes.
11682 var node = finishedWork;
11683 while (true) {
11684 if (node.tag === HostComponent || node.tag === HostText) {
11685 if (before) {
11686 if (isContainer) {
11687 insertInContainerBefore(parent, node.stateNode, before);
11688 } else {
11689 insertBefore(parent, node.stateNode, before);
11690 }
11691 } else {
11692 if (isContainer) {
11693 appendChildToContainer(parent, node.stateNode);
11694 } else {
11695 appendChild(parent, node.stateNode);
11696 }
11697 }
11698 } else if (node.tag === HostPortal) {
11699 // If the insertion itself is a portal, then we don't want to traverse
11700 // down its children. Instead, we'll get insertions from each child in
11701 // the portal directly.
11702 } else if (node.child !== null) {
11703 node.child['return'] = node;
11704 node = node.child;
11705 continue;
11706 }
11707 if (node === finishedWork) {
11708 return;

Callers 1

commitAllHostEffectsFunction · 0.70

Calls 3

getHostParentFiberFunction · 0.70
invariantFunction · 0.70
getHostSiblingFunction · 0.70

Tested by

no test coverage detected