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

activeElement implementation causing crashes when used within vitest #456

Closed
iamcdonald opened this issue Apr 18, 2022 · 2 comments · Fixed by #616
Closed

activeElement implementation causing crashes when used within vitest #456

iamcdonald opened this issue Apr 18, 2022 · 2 comments · Fixed by #616
Assignees
Labels
bug Something isn't working high priority

Comments

@iamcdonald
Copy link

Hi

I know there are other libs at play and there could be various fixes but I'll just outline what I think is going on.
Happy to look at other options, if this is expected behaviour.

Essentially:

  • vitest will spin up a happy-dom env (document) per test file
  • I have a suite of tests (within one file) each of which renders a component and then checks the behaviour of clicking a <button/> within that component.
  • the first test works fine but results in the button rendered for that test becoming the activeElement.
  • the second test then fails due to happy-dom trying to resolve that activeElement(which has now been removed from the dom) against the existing document root.

I think the behaviour I'm seeing stems from this change and was wondering whether it was worth putting a guard around it?

Thanks,

Iain

@capricorn86 capricorn86 added bug Something isn't working high priority labels Apr 26, 2022
@hornta
Copy link

hornta commented Jul 8, 2022

Relates to: #467

@capricorn86 capricorn86 self-assigned this Oct 12, 2022
capricorn86 added a commit that referenced this issue Oct 12, 2022
…to an Element that has been disconnected from the DOM.
capricorn86 added a commit that referenced this issue Oct 12, 2022
…mentation-causing-crashes-when-used-within-vitest

#456@patch: Fixes problem with Document.activeElement still pointing …
@capricorn86
Copy link
Owner

Thanks for reporting @iamcdonald! 🙂

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 release 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.

3 participants