(
returnFiber: Fiber,
oldFiber: Fiber | null,
newChild: any,
lanes: Lanes,
)
| 809 | } |
| 810 | |
| 811 | function updateSlot( |
| 812 | returnFiber: Fiber, |
| 813 | oldFiber: Fiber | null, |
| 814 | newChild: any, |
| 815 | lanes: Lanes, |
| 816 | ): Fiber | null { |
| 817 | // Update the fiber if the keys match, otherwise return null. |
| 818 | const key = oldFiber !== null ? oldFiber.key : null; |
| 819 | |
| 820 | if ( |
| 821 | (typeof newChild === 'string' && newChild !== '') || |
| 822 | typeof newChild === 'number' || |
| 823 | typeof newChild === 'bigint' |
| 824 | ) { |
| 825 | // Text nodes don't have keys. If the previous node is implicitly keyed |
| 826 | // we can continue to replace it without aborting even if it is not a text |
| 827 | // node. |
| 828 | if (key !== null) { |
| 829 | return null; |
| 830 | } |
| 831 | return updateTextNode( |
| 832 | returnFiber, |
| 833 | oldFiber, |
| 834 | // $FlowFixMe[unsafe-addition] Flow doesn't want us to use `+` operator with string and bigint |
| 835 | '' + newChild, |
| 836 | lanes, |
| 837 | ); |
| 838 | } |
| 839 | |
| 840 | if (typeof newChild === 'object' && newChild !== null) { |
| 841 | switch (newChild.$$typeof) { |
| 842 | case REACT_ELEMENT_TYPE: { |
| 843 | if (newChild.key === key) { |
| 844 | const prevDebugInfo = pushDebugInfo(newChild._debugInfo); |
| 845 | const updated = updateElement( |
| 846 | returnFiber, |
| 847 | oldFiber, |
| 848 | newChild, |
| 849 | lanes, |
| 850 | ); |
| 851 | currentDebugInfo = prevDebugInfo; |
| 852 | return updated; |
| 853 | } else { |
| 854 | return null; |
| 855 | } |
| 856 | } |
| 857 | case REACT_PORTAL_TYPE: { |
| 858 | if (newChild.key === key) { |
| 859 | return updatePortal(returnFiber, oldFiber, newChild, lanes); |
| 860 | } else { |
| 861 | return null; |
| 862 | } |
| 863 | } |
| 864 | case REACT_LAZY_TYPE: { |
| 865 | const prevDebugInfo = pushDebugInfo(newChild._debugInfo); |
| 866 | const resolvedChild = resolveLazy((newChild: any)); |
| 867 | const updated = updateSlot( |
| 868 | returnFiber, |
no test coverage detected