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

Wrong select value when option with empty value is selected #1138

Open
modiho opened this issue Oct 19, 2023 · 0 comments
Open

Wrong select value when option with empty value is selected #1138

modiho opened this issue Oct 19, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@modiho
Copy link

modiho commented Oct 19, 2023

Describe the bug

A select element reports the text content of an option that has an empty value as its value, instead of the empty string.

To Reproduce

Execute the following in a Node.js repl:

let {GlobalRegistrator} = require('@happy-dom/global-registrator')

GlobalRegistrator.register();

document.body.innerHTML = `<form>
  <select name="size">
    <option value="">Please choose</option>
    <option value="s">S</option>
    <option value="m">M</option>
  </select>
</form>`

document.querySelector('select').value // => "Please choose"

Expected behavior

document.querySelector('select').value // => "" (empty string)

Screenshots

grafik

Device:

  • Node.js v18.14.1, happy-dom v12.9.1

Additional context

In a browser or JSDom, this works as expected.

@modiho modiho added the bug Something isn't working label Oct 19, 2023
t-wataru added a commit to t-wataru/happy-dom that referenced this issue Mar 10, 2024
capricorn86 added a commit that referenced this issue Mar 11, 2024
fix: [#1138] Modify option node to return empty string even if the value is empty string
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

1 participant