From 09db82b7bd88390d3e3dde26daf584e7696f1bac Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sat, 4 Aug 2018 15:34:26 -0400 Subject: [PATCH 1/2] failing test for #1621 --- .../samples/dynamic-component-in-if/Bar.html | 1 + .../samples/dynamic-component-in-if/Foo.html | 1 + .../samples/dynamic-component-in-if/_config.js | 17 +++++++++++++++++ .../samples/dynamic-component-in-if/main.html | 18 ++++++++++++++++++ 4 files changed, 37 insertions(+) create mode 100644 test/runtime/samples/dynamic-component-in-if/Bar.html create mode 100644 test/runtime/samples/dynamic-component-in-if/Foo.html create mode 100644 test/runtime/samples/dynamic-component-in-if/_config.js create mode 100644 test/runtime/samples/dynamic-component-in-if/main.html 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 000000000000..c5bbc5bb13ac --- /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 000000000000..c62ee08e19f5 --- /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 000000000000..b8600a6846bc --- /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 000000000000..7b5b430ff9bf --- /dev/null +++ b/test/runtime/samples/dynamic-component-in-if/main.html @@ -0,0 +1,18 @@ +{#if x} + +{/if} + + \ No newline at end of file From 48bd0252316c6e4d2251ad10128629ab0c4fb7f5 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sat, 4 Aug 2018 15:46:10 -0400 Subject: [PATCH 2/2] fix #1621 --- src/compile/nodes/Component.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/compile/nodes/Component.ts b/src/compile/nodes/Component.ts index 60de3bcac5a4..fb244e5fba2d 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); });