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

Cannot read properties of undefined (reading 'getRootNode') #467

Closed
smarlhens opened this issue May 3, 2022 · 8 comments · Fixed by #617
Closed

Cannot read properties of undefined (reading 'getRootNode') #467

smarlhens opened this issue May 3, 2022 · 8 comments · Fixed by #617
Assignees
Labels
bug Something isn't working high priority

Comments

@smarlhens
Copy link
Contributor

Hi there 👋🏻 ,

I hope it is the right place to ask, and I apologize if not. I'm currently trying to bump version of happy-dom from 2.51.0 to a greater one using vitest & vue 3 but I'm facing the following error:

image

happy-dom version: 3.1.0 (I've tried multiple version between this one and 2.51.0)
vitest version: 0.10.0

It seems to be related to usage of @headlessui/vue (version 1.5.0) but I haven't found yet the root cause.

Thanks in advance for your help, wish you a nice day ☀️

@capricorn86
Copy link
Owner

Thank you for reporting @smarlhens! 🙂

It might be a bug as a change was made on that part of the code in v2.51.1.

I will investigate what may have caused it.

@capricorn86 capricorn86 added bug Something isn't working high priority labels May 4, 2022
@WonderPanda
Copy link

Hey! I'm also running into issues with this using vitest and react with happy-dom 3.1.1 in my case it seems like it might be related to certain components from the mui component library

@capricorn86
Copy link
Owner

@WonderPanda you don't happen to have a open project that I can test in? 🙂

@knoefel
Copy link

knoefel commented Jun 18, 2022

I'm facing the same error while using a remix template with vitest. You can check out this repo and run the following to reproduce it:

  1. npm i
  2. npm run test

It should fail with the following error message:
Screenshot 2022-06-18 at 17 44 13

The test is located in this file.

Somehow it's only possible to run the first test without errors although both tests are identical. I'm also not 100% sure if this a problem with happy-dom testing-library or vitest. But the error messages links the error to happy-dom.

Thanks in advance for any feedback and for your support!!!

@nilscox
Copy link

nilscox commented Jun 22, 2022

Here is a codesandbox with the minimal possible code to produce this error. Indeed, it only happens when running a second test (when adding a .only to the second test, it does not happen).

@brapifra
Copy link

brapifra commented Jul 7, 2022

I can confirm this is related to happy-dom. I changed the vitest environment to jsdom, and all tests passed.
In my case, it also happens when running a second test.

@hornta
Copy link

hornta commented Jul 8, 2022

I'm blocked by this as well in happy-dom@6.0.2
Reproducible example: https://stackblitz.com/edit/vitest-dev-vitest-ktnq7h

capricorn86 added a commit that referenced this issue Jul 11, 2022
#467@patch: Fix getRootNode() undefined on document.
@capricorn86 capricorn86 self-assigned this Oct 12, 2022
capricorn86 added a commit that referenced this issue Oct 12, 2022
…efore handling custom elements by calling Element.getRootNode().
capricorn86 added a commit that referenced this issue Oct 12, 2022
…ies-of-undefined-reading-getrootnode

#467@patch: Adds check for if the active element is of type Element b…
@capricorn86
Copy link
Owner

Thanks for reporting @smarlhens! 🙂

I am sorry that it has taken such a long time for me to fix this. It has been a lot going on in my private and work life, but now I will have time to focus on Happy DOM again.

I have made a fix. Hopefully it will solve your problem. Feel free to re-open otherwise.

You can read more about the related releases here:
https://github.com/capricorn86/happy-dom/releases/tag/v7.5.10
https://github.com/capricorn86/happy-dom/releases/tag/v7.5.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants