-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Spreading attributes (containing value) on <option>, value attribute get's replaced by option's inner text #9107
Comments
Here's the problem.
} else if (key === '__value') {
/** @type {any} */ (node).value = node[key] = attributes[key];
} I think that need to change it as follows. } else if (key === '__value') {
node[key] = attributes[key];
// @ts-ignore
if (!('value' in attributes)) node.value = node[key];
} |
I'm not at all familiar with the internals of svelte to be honest, however, I'm not sure if this maybe should be a fix for the compiler instead of runtime as I also noticed in the repl JS output it was down to However, looking at your fix In your example Unless there is a further purpose to having the key } else if (key === '__value' && !('value' in attributes)) {
/** @type {any} */ (node).value = node[key] = attributes[key];
} and the |
The same goes for me. I saw your question and tried the following code <select value="email">
<option value='sms' class='option'>SMS</option>
<option value='email' class='option'>E-mail</option>
<option value='letter' class='option'>Letter</option>
</select> It seems like a bug that doesn't recognize that |
Yep you hit the nail on the head, using attributes normally works fine, it's just when spread it's an issue. |
… option's inner text (sveltejs#9125) fixes sveltejs#9107 Apart from the problem with the option the same happens with the textarea.
Describe the bug
Spreading attributes with a
value
attribute on<option>
elements get's replaced with the option's inner textso the following
renders as
When you would expect
I tried looking to see if this is expected behaviour as it seem's svelte intentionally replaces the value with the inner text, but I couldn't find anything or any bugs related to this issue.
Reproduction
https://svelte.dev/repl/4d0c421a2c77451e8ef7e4c4db7a9ca6?version=4.2.0
Logs
No response
System Info
System: OS: macOS 13.4 CPU: (10) arm64 Apple M1 Max Memory: 3.50 GB / 32.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 19.8.1 - /opt/homebrew/bin/node npm: 9.5.1 - /opt/homebrew/bin/npm pnpm: 8.6.3 - ~/Library/pnpm/pnpm Browsers: Chrome: 115.0.5790.170 Chrome Canary: 118.0.5949.0 Safari: 16.5
Severity
annoyance
The text was updated successfully, but these errors were encountered: