(fiber)
| 5306 | } |
| 5307 | |
| 5308 | function findCurrentFiberUsingSlowPath(fiber) { |
| 5309 | var alternate = fiber.alternate; |
| 5310 | if (!alternate) { |
| 5311 | // If there is no alternate, then we only need to check if it is mounted. |
| 5312 | var state = isFiberMountedImpl(fiber); |
| 5313 | !(state !== UNMOUNTED) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0; |
| 5314 | if (state === MOUNTING) { |
| 5315 | return null; |
| 5316 | } |
| 5317 | return fiber; |
| 5318 | } |
| 5319 | // If we have two possible branches, we'll walk backwards up to the root |
| 5320 | // to see what path the root points to. On the way we may hit one of the |
| 5321 | // special cases and we'll deal with them. |
| 5322 | var a = fiber; |
| 5323 | var b = alternate; |
| 5324 | while (true) { |
| 5325 | var parentA = a['return']; |
| 5326 | var parentB = parentA ? parentA.alternate : null; |
| 5327 | if (!parentA || !parentB) { |
| 5328 | // We're at the root. |
| 5329 | break; |
| 5330 | } |
| 5331 | |
| 5332 | // If both copies of the parent fiber point to the same child, we can |
| 5333 | // assume that the child is current. This happens when we bailout on low |
| 5334 | // priority: the bailed out fiber's child reuses the current child. |
| 5335 | if (parentA.child === parentB.child) { |
| 5336 | var child = parentA.child; |
| 5337 | while (child) { |
| 5338 | if (child === a) { |
| 5339 | // We've determined that A is the current branch. |
| 5340 | assertIsMounted(parentA); |
| 5341 | return fiber; |
| 5342 | } |
| 5343 | if (child === b) { |
| 5344 | // We've determined that B is the current branch. |
| 5345 | assertIsMounted(parentA); |
| 5346 | return alternate; |
| 5347 | } |
| 5348 | child = child.sibling; |
| 5349 | } |
| 5350 | // We should never have an alternate for any mounting node. So the only |
| 5351 | // way this could possibly happen is if this was unmounted, if at all. |
| 5352 | invariant(false, 'Unable to find node on an unmounted component.'); |
| 5353 | } |
| 5354 | |
| 5355 | if (a['return'] !== b['return']) { |
| 5356 | // The return pointer of A and the return pointer of B point to different |
| 5357 | // fibers. We assume that return pointers never criss-cross, so A must |
| 5358 | // belong to the child set of A.return, and B must belong to the child |
| 5359 | // set of B.return. |
| 5360 | a = parentA; |
| 5361 | b = parentB; |
| 5362 | } else { |
| 5363 | // The return pointers point to the same fiber. We'll have to use the |
| 5364 | // default, slow path: scan the child sets of each parent alternate to see |
| 5365 | // which child belongs to which set. |
no test coverage detected