Skip to content

Spreading attributes (containing value) on <option>, value attribute get's replaced by option's inner text #9107

@yusaf

Description

@yusaf

Describe the bug

Spreading attributes with a value attribute on <option> elements get's replaced with the option's inner text

so the following

<select>
	<option {...{ value: 'sms', class: 'option' }}>SMS</option>
	<option {...{ value: 'email', class: 'option' }}>E-mail</option>
	<option {...{ value: 'letter', class: 'option' }}>Letter</option>
</select>

renders as

<select>
	<option value="SMS" class="option">SMS</option>
	<option value="E-mail" class="option">E-mail</option>
	<option value="Letter" class="option">Letter</option>
</select>

When you would expect

<select>
	<option value="sms" class="option">SMS</option>
	<option value="email" class="option">E-mail</option>
	<option value="letter" class="option">Letter</option>
</select>

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions