Skip to content

Commit f86376b

Browse files
committed
Add deletion context into test case
1 parent 4794afa commit f86376b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

packages/react-dom/src/__tests__/ReactDOMFragmentRefs-test.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,10 @@ describe('FragmentRefs', () => {
905905
expect(fragmentRef.current.getRootNode()).toBe(document);
906906
});
907907

908+
// The desired behavior here is to return the topmost disconnected element when
909+
// fragment + parent are unmounted. Currently we have a pass during unmount that
910+
// recursively cleans up return pointers of the whole tree. We can change this
911+
// with a future refactor. See: https://github.com/facebook/react/pull/32682#discussion_r2008313082
908912
// @gate enableFragmentRefs
909913
it('returns the topmost disconnected element if the fragment and parent are unmounted', async () => {
910914
const containerRef = React.createRef();
@@ -928,11 +932,13 @@ describe('FragmentRefs', () => {
928932

929933
await act(() => root.render(<Test mounted={true} />));
930934
expect(fragmentRef.current.getRootNode()).toBe(document);
931-
// const fragmentHandle = fragmentRef.current;
932-
// const parentRefHandle = parentRef.current;
935+
const fragmentHandle = fragmentRef.current;
933936
await act(() => root.render(<Test mounted={false} />));
934-
// TODO: Should this pass? fragmentHandle._fragmentFiber.return is null
937+
// TODO: The commented out assertion is the desired behavior. For now, we return
938+
// the fragment instance itself. This is currently the same behavior if you unmount
939+
// the fragment but not the parent. See context above.
935940
// expect(fragmentHandle.getRootNode().id).toBe(parentRefHandle.id);
941+
expect(fragmentHandle.getRootNode()).toBe(fragmentHandle);
936942
});
937943

938944
// @gate enableFragmentRefs

0 commit comments

Comments
 (0)