capricorn86/happy-dom

`details` HTML element works differently in happy-dom compared to js-dom

Closed this issue · 0 comments

Describe the bug

I was working on something that uses the details element and I noticed that testing with react-testing-library behaved differently between one project of ours and another.

I checked versions of vitest (and other vitest dependencies), testing-library and although the stack trace didn't give me any insights, I think I've narrowed it down to happy-dom.

The details element when closed, is supposed to have had the open attribute stripped from it, because open="" and open="false" is actually open.

js-dom seems to work that way, but not happy-dom.

js-dom after closed happy-dom after closed
CleanShot 2024-09-11 at 08 45 53 CleanShot 2024-09-11 at 08 45 40

To Reproduce
Steps to reproduce the behavior:

  1. I've created two CodeSandbox examples to show the difference (albeit in Next.js),
  1. Open the terminal window
  2. Run npm run test

Expected behavior

  • Both happy-dom and js-dom pass

Screenshots

CleanShot.2024-09-11.at.08.57.57.mp4

Device:

For this we're seeing it on MacOS, but because I've submitted with CodeSandbox, I'll be also sharing the hardware of that machine (Linux)

  • OS: Mac, Linux
  • Browser: None
  • Version: 15.7.3

Additional context
Add any other context about the problem here.