happy-dom icon indicating copy to clipboard operation
happy-dom copied to clipboard

`activeElement` implementation causing crashes when used within vitest

Open iamcdonald opened this issue 2 years ago • 1 comments

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

iamcdonald avatar Apr 18 '22 08:04 iamcdonald

Relates to: https://github.com/capricorn86/happy-dom/issues/467

hornta avatar Jul 08 '22 23:07 hornta

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

capricorn86 avatar Oct 12 '22 15:10 capricorn86