Closed MarvinKubus closed 1 month ago
This is the JSDOM behavior but not the default behavior. You can try to make a minimal file example like this one:
<!DOCTYPE html>
<html><body>
<input type="checkbox" />
<script type="text/javascript">
document.querySelector('input').indeterminate = true
</script>
</body></html>
And test it with chrome or firefox, with chrome it constantly make it true when clicked, and with firefox reloading the page will make it false or true changing the value on each reload. The indeterminate state can only be set by javascript and is purely visual. It is the checked state that should determinate the new state when clicked not the indeterminate state at all.
So if your input is checked and indeterminate it should when clicked be unchecked, if it was unchecked and indeterminate it should be checked when clicked.
There's still a problem with the happy-dom implementation, as triggering a click event on the element will not change the indeterminate state at all, but is should be passed to false.
Also I can see the actual implementation sets an attribute indeterminate on the input element but it should not as indeterminate is not meant to be an input attribute.
will propose a PR about this in few days
PR on the way :)
Should be solved by merged #1475 @capricorn86 , @MarvinKubus
Thank you again @malko! :star2:
Describe the bug A checkbox with the indeterminate state being true should go to false when clicked, but this is not happening with happy-dom, it does with jsdom.
To Reproduce Minimal example: https://stackblitz.com/edit/vitest-dev-vitest-rzc6un?file=test%2Fbasic.test.ts Switch the happy-dom to jsdom there to see the test succeed.
Expected behavior When clicking a checkbox element, I expect the indeterminate state to switch to false.