Merge pull request #3314 from sveltejs/gh-3312

quote props if necessary in SSR mode
pull/3316/head
Rich Harris 5 years ago committed by GitHub
commit 0d3b7c35c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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