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

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

Closed
mikedidomizio opened this issue Sep 11, 2024 · 0 comments
Closed
Labels
bug Something isn't working

Comments

@mikedidomizio
Copy link
Contributor

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.

@mikedidomizio mikedidomizio added the bug Something isn't working label Sep 11, 2024
capricorn86 added a commit to mikedidomizio/happy-dom that referenced this issue Nov 3, 2024
capricorn86 added a commit that referenced this issue Nov 4, 2024
…hing a click event on a summary element which is a child of the details element (#1534)

* fix: [#1534] Fix click event not removing open attribute

* chore: [#1534] Adds unit tests and adds some additional logic according to the spec

---------

Co-authored-by: David Ortner <david@ortner.se>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants