Skip to content

Commit 1427206

Browse files
authored
Merge pull request #3146 from sveltejs/gh-2135
handle circular values when rendering bindings
2 parents 2915cf9 + 4082566 commit 1427206

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

src/runtime/internal/ssr.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export function get_store_value<T>(store: Readable<T>): T | undefined {
122122

123123
export function add_attribute(name, value) {
124124
if (!value) return '';
125-
return ` ${name}${value === true ? '' : `=${JSON.stringify(value)}`}`;
125+
return ` ${name}${value === true ? '' : `=${typeof value === 'string' ? JSON.stringify(value) : `"${value}"`}`}`;
126126
}
127127

128128
export function add_classes(classes) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export default {
2+
html: `
3+
<select>
4+
<option value="[object Object]">wheeee</option>
5+
</select>
6+
`,
7+
8+
ssrHtml: `
9+
<select value="[object Object]">
10+
<option value="[object Object]">wheeee</option>
11+
</select>
12+
`
13+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<script>
2+
let obj = {};
3+
obj.self = obj;
4+
5+
let selected = obj;
6+
</script>
7+
8+
<select bind:value={selected}>
9+
<option value={obj}>wheeee</option>
10+
</select>

0 commit comments

Comments
 (0)