diff --git a/src/compile/nodes/Component.ts b/src/compile/nodes/Component.ts index 60de3bcac5..fb244e5fba 100644 --- a/src/compile/nodes/Component.ts +++ b/src/compile/nodes/Component.ts @@ -78,6 +78,10 @@ export default class Component extends Node { ) { this.cannotUseInnerHTML(); + if (this.expression) { + block.addDependencies(this.expression.dependencies); + } + this.attributes.forEach(attr => { block.addDependencies(attr.dependencies); }); diff --git a/test/runtime/samples/dynamic-component-in-if/Bar.html b/test/runtime/samples/dynamic-component-in-if/Bar.html new file mode 100644 index 0000000000..c5bbc5bb13 --- /dev/null +++ b/test/runtime/samples/dynamic-component-in-if/Bar.html @@ -0,0 +1 @@ +
Bar
\ No newline at end of file diff --git a/test/runtime/samples/dynamic-component-in-if/Foo.html b/test/runtime/samples/dynamic-component-in-if/Foo.html new file mode 100644 index 0000000000..c62ee08e19 --- /dev/null +++ b/test/runtime/samples/dynamic-component-in-if/Foo.html @@ -0,0 +1 @@ +Foo
\ No newline at end of file diff --git a/test/runtime/samples/dynamic-component-in-if/_config.js b/test/runtime/samples/dynamic-component-in-if/_config.js new file mode 100644 index 0000000000..b8600a6846 --- /dev/null +++ b/test/runtime/samples/dynamic-component-in-if/_config.js @@ -0,0 +1,17 @@ +export default { + html: ` +Foo
+ `, + + test(assert, component, target) { + const { Bar } = component.get(); + + component.set({ + x: Bar + }); + + assert.htmlEqual(target.innerHTML, ` +Bar
+ `); + } +}; \ No newline at end of file diff --git a/test/runtime/samples/dynamic-component-in-if/main.html b/test/runtime/samples/dynamic-component-in-if/main.html new file mode 100644 index 0000000000..7b5b430ff9 --- /dev/null +++ b/test/runtime/samples/dynamic-component-in-if/main.html @@ -0,0 +1,18 @@ +{#if x} +