( prev: ContextNode<any>, next: ContextNode<any>, )
| 102 | } |
| 103 | |
| 104 | function popPreviousToCommonLevel( |
| 105 | prev: ContextNode<any>, |
| 106 | next: ContextNode<any>, |
| 107 | ): void { |
| 108 | popNode(prev); |
| 109 | const parentPrev = prev.parent; |
| 110 | |
| 111 | if (parentPrev === null) { |
| 112 | throw new Error( |
| 113 | 'The depth must equal at least at zero before reaching the root. This is a bug in React.', |
| 114 | ); |
| 115 | } |
| 116 | |
| 117 | if (parentPrev.depth === next.depth) { |
| 118 | // We found the same level. Now we just need to find a shared ancestor. |
| 119 | popToNearestCommonAncestor(parentPrev, next); |
| 120 | } else { |
| 121 | // We must still be deeper. |
| 122 | popPreviousToCommonLevel(parentPrev, next); |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | function popNextToCommonLevel( |
| 127 | prev: ContextNode<any>, |
no test coverage detected