(fiber: Fiber)
| 1246 | } |
| 1247 | |
| 1248 | function detachFiberMutation(fiber: Fiber) { |
| 1249 | // Cut off the return pointer to disconnect it from the tree. |
| 1250 | // This enables us to detect and warn against state updates on an unmounted component. |
| 1251 | // It also prevents events from bubbling from within disconnected components. |
| 1252 | // |
| 1253 | // Ideally, we should also clear the child pointer of the parent alternate to let this |
| 1254 | // get GC:ed but we don't know which for sure which parent is the current |
| 1255 | // one so we'll settle for GC:ing the subtree of this child. |
| 1256 | // This child itself will be GC:ed when the parent updates the next time. |
| 1257 | // |
| 1258 | // Note that we can't clear child or sibling pointers yet. |
| 1259 | // They're needed for passive effects and for findDOMNode. |
| 1260 | // We defer those fields, and all other cleanup, to the passive phase (see detachFiberAfterEffects). |
| 1261 | // |
| 1262 | // Don't reset the alternate yet, either. We need that so we can detach the |
| 1263 | // alternate's fields in the passive phase. Clearing the return pointer is |
| 1264 | // sufficient for findDOMNode semantics. |
| 1265 | const alternate = fiber.alternate; |
| 1266 | if (alternate !== null) { |
| 1267 | alternate.return = null; |
| 1268 | } |
| 1269 | fiber.return = null; |
| 1270 | } |
| 1271 | |
| 1272 | function detachFiberAfterEffects(fiber: Fiber) { |
| 1273 | const alternate = fiber.alternate; |
no outgoing calls
no test coverage detected