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

Function commitPlacement

code/redux/public/app.js:11908–11976  ·  view source on GitHub ↗
(finishedWork)

Source from the content-addressed store, hash-verified

11906 }
11907
11908 function commitPlacement(finishedWork) {
11909 // Recursively insert all host nodes into the parent.
11910 var parentFiber = getHostParentFiber(finishedWork);
11911 var parent = void 0;
11912 var isContainer = void 0;
11913 switch (parentFiber.tag) {
11914 case HostComponent:
11915 parent = parentFiber.stateNode;
11916 isContainer = false;
11917 break;
11918 case HostRoot:
11919 parent = parentFiber.stateNode.containerInfo;
11920 isContainer = true;
11921 break;
11922 case HostPortal:
11923 parent = parentFiber.stateNode.containerInfo;
11924 isContainer = true;
11925 break;
11926 default:
11927 invariant(false, 'Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue.');
11928 }
11929 if (parentFiber.effectTag & ContentReset) {
11930 // Reset the text content of the parent before doing any insertions
11931 resetTextContent(parent);
11932 // Clear ContentReset from the effect tag
11933 parentFiber.effectTag &= ~ContentReset;
11934 }
11935
11936 var before = getHostSibling(finishedWork);
11937 // We only have the top Fiber that was inserted but we need recurse down its
11938 // children to find all the terminal nodes.
11939 var node = finishedWork;
11940 while (true) {
11941 if (node.tag === HostComponent || node.tag === HostText) {
11942 if (before) {
11943 if (isContainer) {
11944 insertInContainerBefore(parent, node.stateNode, before);
11945 } else {
11946 insertBefore(parent, node.stateNode, before);
11947 }
11948 } else {
11949 if (isContainer) {
11950 appendChildToContainer(parent, node.stateNode);
11951 } else {
11952 appendChild(parent, node.stateNode);
11953 }
11954 }
11955 } else if (node.tag === HostPortal) {
11956 // If the insertion itself is a portal, then we don't want to traverse
11957 // down its children. Instead, we'll get insertions from each child in
11958 // the portal directly.
11959 } else if (node.child !== null) {
11960 node.child['return'] = node;
11961 node = node.child;
11962 continue;
11963 }
11964 if (node === finishedWork) {
11965 return;

Callers 1

commitAllHostEffectsFunction · 0.70

Calls 3

getHostParentFiberFunction · 0.70
invariantFunction · 0.70
getHostSiblingFunction · 0.70

Tested by

no test coverage detected