quote props if necessary in SSR mode - fixes #3312

pull/3314/head
Rich Harris 5 years ago
parent dbf503b9e1
commit 0fe04561b2

@ -58,7 +58,7 @@ export default function(node: InlineComponent, renderer: Renderer, options: Rend
if (attribute.is_spread) {
return snip(attribute.expression);
} else {
return `{ ${attribute.name}: ${get_attribute_value(attribute)} }`;
return `{ ${quote_name_if_necessary(attribute.name)}: ${get_attribute_value(attribute)} }`;
}
})
.concat(binding_props.map(p => `{ ${p} }`))
@ -67,7 +67,7 @@ export default function(node: InlineComponent, renderer: Renderer, options: Rend
} else {
props = stringify_props(
node.attributes
.map(attribute => `${attribute.name}: ${get_attribute_value(attribute)}`)
.map(attribute => `${quote_name_if_necessary(attribute.name)}: ${get_attribute_value(attribute)}`)
.concat(binding_props)
);
}

@ -0,0 +1,12 @@
export default {
props: {
foo: 1
},
html: `1`,
async test({ assert, component, target }) {
component.foo = 2;
assert.htmlEqual(target.innerHTML, `2`);
}
};

@ -0,0 +1,7 @@
<script>
import Nested from './Nested.svelte';
export let foo;
</script>
<Nested x-y-z={foo}/>
Loading…
Cancel
Save