happy-dom
happy-dom copied to clipboard
`activeElement` implementation causing crashes when used within vitest
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 thatactiveElement
(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
Relates to: https://github.com/capricorn86/happy-dom/issues/467
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