From cdc0270ef1c74c30a5610d8765fc66194ec8ce65 Mon Sep 17 00:00:00 2001 From: Tan Li Hau Date: Tue, 17 Mar 2020 00:10:20 +0800 Subject: [PATCH] fix deconflicting variable name for slot fallback (#4564) --- src/compiler/compile/render_dom/wrappers/Slot.ts | 2 +- .../samples/component-slot-fallback-3/Inner.svelte | 6 ++++++ .../runtime/samples/component-slot-fallback-3/_config.js | 6 ++++++ .../samples/component-slot-fallback-3/main.svelte | 9 +++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 test/runtime/samples/component-slot-fallback-3/Inner.svelte create mode 100644 test/runtime/samples/component-slot-fallback-3/_config.js create mode 100644 test/runtime/samples/component-slot-fallback-3/main.svelte diff --git a/src/compiler/compile/render_dom/wrappers/Slot.ts b/src/compiler/compile/render_dom/wrappers/Slot.ts index 37b10c2ea3..f287198132 100644 --- a/src/compiler/compile/render_dom/wrappers/Slot.ts +++ b/src/compiler/compile/render_dom/wrappers/Slot.ts @@ -38,6 +38,7 @@ export default class SlotWrapper extends Wrapper { name: this.renderer.component.get_unique_name(`fallback_block`), type: 'fallback' }); + renderer.blocks.push(this.fallback); } this.fragment = new FragmentWrapper( @@ -115,7 +116,6 @@ export default class SlotWrapper extends Wrapper { if (this.fallback) { this.fragment.render(this.fallback, null, x`#nodes` as Identifier); - renderer.blocks.push(this.fallback); } const slot = block.get_unique_name(`${sanitize(slot_name)}_slot`); diff --git a/test/runtime/samples/component-slot-fallback-3/Inner.svelte b/test/runtime/samples/component-slot-fallback-3/Inner.svelte new file mode 100644 index 0000000000..db2af272d2 --- /dev/null +++ b/test/runtime/samples/component-slot-fallback-3/Inner.svelte @@ -0,0 +1,6 @@ + +
Hello
+
world
+
Bye
+
World
+
diff --git a/test/runtime/samples/component-slot-fallback-3/_config.js b/test/runtime/samples/component-slot-fallback-3/_config.js new file mode 100644 index 0000000000..b5591fb5e0 --- /dev/null +++ b/test/runtime/samples/component-slot-fallback-3/_config.js @@ -0,0 +1,6 @@ +export default { + html: ` +
Hello World
+
Hello
world
Bye
World
+ `, +}; diff --git a/test/runtime/samples/component-slot-fallback-3/main.svelte b/test/runtime/samples/component-slot-fallback-3/main.svelte new file mode 100644 index 0000000000..eda7ea60e4 --- /dev/null +++ b/test/runtime/samples/component-slot-fallback-3/main.svelte @@ -0,0 +1,9 @@ + + + +
Hello World
+
+ +