Skip to content

Commit

Permalink
Let text and fragment nodes inherit their parent as their owner
Browse files Browse the repository at this point in the history
They don't have their own owner so to get some owner stacks we can use
the parent as the owner.

Effectively this also means using the parent's debugTask for native stacks.

This ensures that createTask is active when a HostText node runs its validation.
  • Loading branch information
sebmarkbage committed Jul 10, 2024
1 parent c07aaee commit b409317
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions packages/react-reconciler/src/ReactChildFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,11 @@ function createChildReconciler(
const created = createFiberFromText(textContent, returnFiber.mode, lanes);
created.return = returnFiber;
if (__DEV__) {
// We treat the parent as the owner for stack purposes.
created._debugOwner = returnFiber;
if (enableOwnerStacks) {
created._debugTask = returnFiber._debugTask;
}
created._debugInfo = currentDebugInfo;
}
return created;
Expand Down Expand Up @@ -630,6 +635,11 @@ function createChildReconciler(
);
created.return = returnFiber;
if (__DEV__) {
// We treat the parent as the owner for stack purposes.
created._debugOwner = returnFiber;
if (enableOwnerStacks) {
created._debugTask = returnFiber._debugTask;
}
created._debugInfo = currentDebugInfo;
}
return created;
Expand Down Expand Up @@ -665,6 +675,11 @@ function createChildReconciler(
);
created.return = returnFiber;
if (__DEV__) {
// We treat the parent as the owner for stack purposes.
created._debugOwner = returnFiber;
if (enableOwnerStacks) {
created._debugTask = returnFiber._debugTask;
}
created._debugInfo = currentDebugInfo;
}
return created;
Expand Down Expand Up @@ -729,6 +744,11 @@ function createChildReconciler(
);
created.return = returnFiber;
if (__DEV__) {
// We treat the parent as the owner for stack purposes.
created._debugOwner = returnFiber;
if (enableOwnerStacks) {
created._debugTask = returnFiber._debugTask;
}
const prevDebugInfo = pushDebugInfo(newChild._debugInfo);
created._debugInfo = currentDebugInfo;
currentDebugInfo = prevDebugInfo;
Expand Down Expand Up @@ -1610,6 +1630,14 @@ function createChildReconciler(
deleteRemainingChildren(returnFiber, currentFirstChild);
const created = createFiberFromText(textContent, returnFiber.mode, lanes);
created.return = returnFiber;
if (__DEV__) {
// We treat the parent as the owner for stack purposes.
created._debugOwner = returnFiber;
if (enableOwnerStacks) {
created._debugTask = returnFiber._debugTask;
}
created._debugInfo = currentDebugInfo;
}
return created;
}

Expand Down Expand Up @@ -1683,6 +1711,11 @@ function createChildReconciler(
);
created.return = returnFiber;
if (__DEV__) {
// We treat the parent as the owner for stack purposes.
created._debugOwner = returnFiber;
if (enableOwnerStacks) {
created._debugTask = returnFiber._debugTask;
}
created._debugInfo = currentDebugInfo;
}
validateFragmentProps(element, created, returnFiber);
Expand Down

0 comments on commit b409317

Please sign in to comment.