Skip to content

Select multiple value does not get set with spread props #4392

@nathancahill

Description

@nathancahill

Describe the bug

This works:

<script>
  let value = ['Hello', 'World'];
</script>

<select multiple {value}>
  <option>Hello</option>
  <option>World</option>
</select>

Adding any type of spread, even an empty object {...{}}, causes the value not to be set:

<script>
  let value = ['Hello', 'World'];
</script>

<select multiple {value} {...{}}>
  <option>Hello</option>
  <option>World</option>
</select>

Logs
No logs.

To Reproduce
https://svelte.dev/repl/99bd5ebecc464e328972252e287ab716?version=3.18.1

Expected behavior
The <select multiple> value should be set.

Stacktraces
No stacktrace.

Information about your Svelte project:

  • Your browser and the version: Firefox 72, Chrome 80, Safari 13

  • Your operating system: OS X 10.14.6

  • Svelte version: 3.18.1

  • Rollup

Severity
Mildly annoying, needed to build a complex workaround for a simple thing.

Additional Context
Further debugging, it seems like the issue might be related to this line in Element/Binding.ts#L212

The check is node.get_static_attribute_value('multiple') === true. Adding a spread causes this check fail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions