Skip to content

Commit 0d3b7c3

Browse files
authored
Merge pull request #3314 from sveltejs/gh-3312
quote props if necessary in SSR mode
2 parents dbf503b + 0fe0456 commit 0d3b7c3

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

src/compiler/compile/render_ssr/handlers/InlineComponent.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export default function(node: InlineComponent, renderer: Renderer, options: Rend
5858
if (attribute.is_spread) {
5959
return snip(attribute.expression);
6060
} else {
61-
return `{ ${attribute.name}: ${get_attribute_value(attribute)} }`;
61+
return `{ ${quote_name_if_necessary(attribute.name)}: ${get_attribute_value(attribute)} }`;
6262
}
6363
})
6464
.concat(binding_props.map(p => `{ ${p} }`))
@@ -67,7 +67,7 @@ export default function(node: InlineComponent, renderer: Renderer, options: Rend
6767
} else {
6868
props = stringify_props(
6969
node.attributes
70-
.map(attribute => `${attribute.name}: ${get_attribute_value(attribute)}`)
70+
.map(attribute => `${quote_name_if_necessary(attribute.name)}: ${get_attribute_value(attribute)}`)
7171
.concat(binding_props)
7272
);
7373
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{$$props['x-y-z']}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export default {
2+
props: {
3+
foo: 1
4+
},
5+
6+
html: `1`,
7+
8+
async test({ assert, component, target }) {
9+
component.foo = 2;
10+
assert.htmlEqual(target.innerHTML, `2`);
11+
}
12+
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<script>
2+
import Nested from './Nested.svelte';
3+
4+
export let foo;
5+
</script>
6+
7+
<Nested x-y-z={foo}/>

0 commit comments

Comments
 (0)