Skip to content

Commit 7c51094

Browse files
authored
Merge pull request #1630 from sveltejs/gh-1621
register dependencies of dynamic component expressions
2 parents 6012c96 + 48bd025 commit 7c51094

File tree

5 files changed

+41
-0
lines changed

5 files changed

+41
-0
lines changed

src/compile/nodes/Component.ts

+4
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ export default class Component extends Node {
7878
) {
7979
this.cannotUseInnerHTML();
8080

81+
if (this.expression) {
82+
block.addDependencies(this.expression.dependencies);
83+
}
84+
8185
this.attributes.forEach(attr => {
8286
block.addDependencies(attr.dependencies);
8387
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<p>Bar</p>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<p>Foo</p>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export default {
2+
html: `
3+
<p>Foo</p>
4+
`,
5+
6+
test(assert, component, target) {
7+
const { Bar } = component.get();
8+
9+
component.set({
10+
x: Bar
11+
});
12+
13+
assert.htmlEqual(target.innerHTML, `
14+
<p>Bar</p>
15+
`);
16+
}
17+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{#if x}
2+
<svelte:component this={x}/>
3+
{/if}
4+
5+
<script>
6+
import Foo from './Foo.html';
7+
import Bar from './Bar.html';
8+
9+
export default {
10+
data() {
11+
return {
12+
x: Foo,
13+
Foo,
14+
Bar
15+
};
16+
}
17+
};
18+
</script>

0 commit comments

Comments
 (0)