Open
Description
Just opening this for tracking with the associated PR: #1330 .
When:
render(<Component />, { container: document });
(Untested: This bug may require that Component
render a <body>
element.)
Then:
TypeError: Cannot read properties of null (reading 'removeChild')
Because:
// pure.js
if (container.parentNode === document.body) {
document.body.removeChild(container);
}
If we first check that document.body
is not null, then this error will not occur.
Metadata
Metadata
Assignees
Labels
No labels
Activity
document
containers in cleanup #1330MatanBobi commentedon May 22, 2024
@quisido Can you please add a reproduction for this? As long as a document exists, JSDOM implicitly creates
document.body
for you.quisido commentedon May 22, 2024
Are you unable to reproduce it? I've hit this in two separate projects just by setting container to document.
As far as I'm aware, using
container: document
in any existing test is the only step required to reproduce this.MatanBobi commentedon May 22, 2024
Two points here:
m-zuro commentedon Oct 10, 2024
@MatanBobi Running into same issue as described here. Here is reproducible example (clone from your StackBlitz but switched from vitest to jest): https://stackblitz.com/edit/stackblitz-starters-3sze3m?file=app%2Flayout.spec.tsx
MatanBobi commentedon Oct 10, 2024
@m-zuro Thanks.
In the reproduction you've attached here, the test isn't passing:
So I think there's a misconfiguration there.
m-zuro commentedon Oct 10, 2024
@MatanBobi sorry, copy/paste job. Updated now, can you re try pls?
MatanBobi commentedon Dec 7, 2024
Sorry it took me a while @m-zuro. This error is odd to me, the only place we're calling
document.body.removeChild
is after this if statement:When I run this test locally in our repo, it passes. I'm trying to understand if there's anything different here.