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

Function commitPlacement

code/dependency-injection/public/app.js:11750–11818  ·  view source on GitHub ↗
(finishedWork)

Source from the content-addressed store, hash-verified

11748 }
11749
11750 function commitPlacement(finishedWork) {
11751 // Recursively insert all host nodes into the parent.
11752 var parentFiber = getHostParentFiber(finishedWork);
11753 var parent = void 0;
11754 var isContainer = void 0;
11755 switch (parentFiber.tag) {
11756 case HostComponent:
11757 parent = parentFiber.stateNode;
11758 isContainer = false;
11759 break;
11760 case HostRoot:
11761 parent = parentFiber.stateNode.containerInfo;
11762 isContainer = true;
11763 break;
11764 case HostPortal:
11765 parent = parentFiber.stateNode.containerInfo;
11766 isContainer = true;
11767 break;
11768 default:
11769 invariant(false, 'Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue.');
11770 }
11771 if (parentFiber.effectTag & ContentReset) {
11772 // Reset the text content of the parent before doing any insertions
11773 resetTextContent(parent);
11774 // Clear ContentReset from the effect tag
11775 parentFiber.effectTag &= ~ContentReset;
11776 }
11777
11778 var before = getHostSibling(finishedWork);
11779 // We only have the top Fiber that was inserted but we need recurse down its
11780 // children to find all the terminal nodes.
11781 var node = finishedWork;
11782 while (true) {
11783 if (node.tag === HostComponent || node.tag === HostText) {
11784 if (before) {
11785 if (isContainer) {
11786 insertInContainerBefore(parent, node.stateNode, before);
11787 } else {
11788 insertBefore(parent, node.stateNode, before);
11789 }
11790 } else {
11791 if (isContainer) {
11792 appendChildToContainer(parent, node.stateNode);
11793 } else {
11794 appendChild(parent, node.stateNode);
11795 }
11796 }
11797 } else if (node.tag === HostPortal) {
11798 // If the insertion itself is a portal, then we don't want to traverse
11799 // down its children. Instead, we'll get insertions from each child in
11800 // the portal directly.
11801 } else if (node.child !== null) {
11802 node.child['return'] = node;
11803 node = node.child;
11804 continue;
11805 }
11806 if (node === finishedWork) {
11807 return;

Callers 1

commitAllHostEffectsFunction · 0.70

Calls 3

getHostParentFiberFunction · 0.70
invariantFunction · 0.70
getHostSiblingFunction · 0.70

Tested by

no test coverage detected