add test, tweak codegen

pull/1473/head
Rich Harris 7 years ago
parent 247cfcfc7c
commit 63cd3d0601

@ -155,7 +155,7 @@ export default class Component extends Node {
componentInitProperties.push(`data: ${name_initial_data}`);
}
if ((!usesSpread && this.attributes.filter(a => a.isDynamic).length) || this.bindings.length) {
if (!usesSpread && (this.attributes.filter(a => a.isDynamic).length || this.bindings.length)) {
updates.push(`var ${name_changes} = {};`);
}
@ -209,7 +209,7 @@ export default class Component extends Node {
updates.push(deindent`
var ${name_changes} = ${allDependencies.size === 1 ? `${conditions}` : `(${conditions})`} ? @getSpreadUpdate(${levels}, [
${changes.join(',\n')}
]) : ${name_changes};
]) : {};
`);
} else {
this.attributes

@ -0,0 +1,2 @@
<p>{value}</p>
<input bind:value/>

@ -0,0 +1,18 @@
export default {
html: `
<p>foo</p>
<input>
`,
test (assert, component, target, window) {
const input = target.querySelector('input');
input.value = 'bar';
input.dispatchEvent(new window.Event('input'));
assert.htmlEqual(target.innerHTML, `
<p>bar</p>
<input>
`);
}
};

@ -0,0 +1,15 @@
<svelte:component this={Widget} {...props} bind:value="x" />
<script>
import Widget from './Widget.html';
export default {
data() {
return {
Widget,
x: 'foo',
props: {}
}
}
};
</script>
Loading…
Cancel
Save