Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When container is document, cleanup steps fails with "TypeError: Cannot read properties of null (reading 'removeChild')" #1329

Open
quisido opened this issue May 20, 2024 · 3 comments · May be fixed by #1330

Comments

@quisido
Copy link

quisido commented May 20, 2024

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.

@quisido quisido linked a pull request May 20, 2024 that will close this issue
4 tasks
@MatanBobi
Copy link
Member

@quisido Can you please add a reproduction for this? As long as a document exists, JSDOM implicitly creates document.body for you.

@quisido
Copy link
Author

quisido commented 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.

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
Copy link
Member

Two points here:

  1. We do not have the capacity to try and reproduce every issue that's raised in this repo, that's why we ask people who create issues to provide a cloneable reproduction.
  2. When testing layout components was raised here, I created a solution and It doesn't reproduce there: https://stackblitz.com/edit/rtl-template-68mwxh?file=src%2FApp.test.tsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants