Closed as not planned
Closed as not planned
Description
Describe the bug
If we return data of type new Map() from corresponding page endpoints, the component getting rendered in browser is unable to get the data, while server side is able to get it correctly.
Reproduction
index.svelte
<script>
export let initialData;
let map = initialData.map;
console.log('in index.svelte map', map);
</script>
index.js
export async function get({ params }) {
let map = new Map();
map.set("key", "value");
let initialData = { "map": map }
return {
body: {
initialData
}
};
};
Below is what we see, as you can see on server side it shows map values {'key' : 'value'}, but on the browser its empty.
Moreoever, the data type itself is changed, on server its still Map, but on browser its changed to dictionary ({}).
But if we change the type to diction in index.js as follows
export async function get({ params }) {
let map = {};
map["key"] = "value";
let initialData = { "map": map }
return {
body: {
initialData
}
}
}
then both server and browser gets the data correctly as shown below.
Logs
No response
System Info
System:
OS: Linux 5.15 Ubuntu 22.04 LTS 22.04 LTS (Jammy Jellyfish)
CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
Memory: 3.03 GB / 15.42 GB
Container: Yes
Shell: 5.1.16 - /bin/bash
Binaries:
Node: 16.15.0 - ~/.nvm/versions/node/v16.15.0/bin/node
npm: 8.13.2 - ~/.nvm/versions/node/v16.15.0/bin/npm
Browsers:
Brave Browser: 103.1.41.96
Chrome: 103.0.5060.114
Firefox: 102.0.1
npmPackages:
@sveltejs/adapter-auto: next => 1.0.0-next.55
@sveltejs/kit: next => 1.0.0-next.367
svelte: ^3.46.0 => 3.49.0
vite: ^2.9.13 => 2.9.14
Severity
serious, but I can work around it
Additional Information
No response
Metadata
Metadata
Assignees
Labels
No labels