Skip to content

Bind to a Map() Object not possible #5721

Open
@firewave-remo

Description

@firewave-remo

Describe the bug
I am not sure if this should work or if it's a feature request in the end.

It is easily possible to bind to a normal Object {} with "keys", but it seems not to be possible if i have a Map object. I have tried to simplify the repl as much as possible.

Works:

	const id = 1;
	
	const obj = {};
	obj[id] = {x: 0, y: 0};
...
<input type="range" min="0" max="100" bind:value={obj[id].x} />

Does not work:

	const map = new Map();
	map.set(id, {x: 50, y: 50});
...
<input type="range" min="0" max="100" bind:value={map.get(id).x} />

Full repl see link.

To Reproduce
Repl:
https://svelte.dev/repl/947950a2c1754c20a86c39f34924485a?version=3.30.0

Expected behavior
Can bind to object stored in Map

Severity
Low

Context
In my real Application the Map object is a Store with lots of objects in it which I access by key. I wanted to do a performance comparison between Objects and Maps for my specific case.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions