Skip to content

Commit

Permalink
spread on dynamic component - fixes #1307
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Apr 3, 2018
1 parent db21e80 commit ee7f676
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/generators/nodes/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,10 @@ export default class Component extends Node {
}
});

block.addVariable(levels);

statements.push(deindent`
var ${levels} = [
${levels} = [
${initialProps.join(',\n')}
];
Expand Down
1 change: 1 addition & 0 deletions test/runtime/samples/spread-component-dynamic/Foo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>a: {{a}}</p>
21 changes: 21 additions & 0 deletions test/runtime/samples/spread-component-dynamic/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export default {
data: {
props: {
a: 1,
},
},

html: `
<p>a: 1</p>
`,

test(assert, component, target) {
component.set({
props: {
a: 2,
},
});

assert.htmlEqual(target.innerHTML, `<p>a: 2</p>`);
},
};
13 changes: 13 additions & 0 deletions test/runtime/samples/spread-component-dynamic/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<:Component {Foo} {{...props}} />

<script>
import Foo from './Foo.html';

export default {
data() {
return {
Foo
};
}
};
</script>

0 comments on commit ee7f676

Please sign in to comment.