MCPcopy Create free account
hub / github.com/microsoft/SandDance / updateSlot

Function updateSlot

docs/external/js/react-dom.development.js:13798–13856  ·  view source on GitHub ↗
(returnFiber, oldFiber, newChild, expirationTime)

Source from the content-addressed store, hash-verified

13796 }
13797
13798 function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {
13799 // Update the fiber if the keys match, otherwise return null.
13800 var key = oldFiber !== null ? oldFiber.key : null;
13801
13802 if (typeof newChild === 'string' || typeof newChild === 'number') {
13803 // Text nodes don't have keys. If the previous node is implicitly keyed
13804 // we can continue to replace it without aborting even if it is not a text
13805 // node.
13806 if (key !== null) {
13807 return null;
13808 }
13809
13810 return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);
13811 }
13812
13813 if (typeof newChild === 'object' && newChild !== null) {
13814 switch (newChild.$$typeof) {
13815 case REACT_ELEMENT_TYPE:
13816 {
13817 if (newChild.key === key) {
13818 if (newChild.type === REACT_FRAGMENT_TYPE) {
13819 return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);
13820 }
13821
13822 return updateElement(returnFiber, oldFiber, newChild, expirationTime);
13823 } else {
13824 return null;
13825 }
13826 }
13827
13828 case REACT_PORTAL_TYPE:
13829 {
13830 if (newChild.key === key) {
13831 return updatePortal(returnFiber, oldFiber, newChild, expirationTime);
13832 } else {
13833 return null;
13834 }
13835 }
13836 }
13837
13838 if (isArray$1(newChild) || getIteratorFn(newChild)) {
13839 if (key !== null) {
13840 return null;
13841 }
13842
13843 return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);
13844 }
13845
13846 throwOnInvalidObjectType(returnFiber, newChild);
13847 }
13848
13849 {
13850 if (typeof newChild === 'function') {
13851 warnOnFunctionType();
13852 }
13853 }
13854
13855 return null;

Callers 2

reconcileChildrenArrayFunction · 0.85

Calls 7

updateTextNodeFunction · 0.85
updateFragmentFunction · 0.85
updateElementFunction · 0.85
updatePortalFunction · 0.85
throwOnInvalidObjectTypeFunction · 0.85
warnOnFunctionTypeFunction · 0.85
getIteratorFnFunction · 0.70

Tested by

no test coverage detected