From aa653558d0b4eaf8023c44ad161799b376101898 Mon Sep 17 00:00:00 2001 From: Richard Harris Date: Sat, 13 Apr 2019 19:34:42 -0400 Subject: [PATCH] only create fallback content if no slot is provided - fixes #2354 --- src/compile/render-dom/wrappers/Slot.ts | 2 ++ test/hydration/samples/text-fallback/Nested.svelte | 7 +++++++ test/hydration/samples/text-fallback/_after.html | 4 ++++ test/hydration/samples/text-fallback/_before.html | 4 ++++ test/hydration/samples/text-fallback/main.svelte | 11 +++++++++++ 5 files changed, 28 insertions(+) create mode 100644 test/hydration/samples/text-fallback/Nested.svelte create mode 100644 test/hydration/samples/text-fallback/_after.html create mode 100644 test/hydration/samples/text-fallback/_before.html create mode 100644 test/hydration/samples/text-fallback/main.svelte diff --git a/src/compile/render-dom/wrappers/Slot.ts b/src/compile/render-dom/wrappers/Slot.ts index 38896b4546..89a575910f 100644 --- a/src/compile/render-dom/wrappers/Slot.ts +++ b/src/compile/render-dom/wrappers/Slot.ts @@ -106,6 +106,7 @@ export default class SlotWrapper extends Wrapper { let mount_before = block.builders.mount.toString(); block.builders.create.push_condition(`!${slot}`); + block.builders.claim.push_condition(`!${slot}`); block.builders.hydrate.push_condition(`!${slot}`); block.builders.mount.push_condition(`!${slot}`); block.builders.update.push_condition(`!${slot}`); @@ -118,6 +119,7 @@ export default class SlotWrapper extends Wrapper { block.event_listeners = listeners; block.builders.create.pop_condition(); + block.builders.claim.pop_condition(); block.builders.hydrate.pop_condition(); block.builders.mount.pop_condition(); block.builders.update.pop_condition(); diff --git a/test/hydration/samples/text-fallback/Nested.svelte b/test/hydration/samples/text-fallback/Nested.svelte new file mode 100644 index 0000000000..b5b69bdc97 --- /dev/null +++ b/test/hydration/samples/text-fallback/Nested.svelte @@ -0,0 +1,7 @@ +
+ + foo fallback + + + +
\ No newline at end of file diff --git a/test/hydration/samples/text-fallback/_after.html b/test/hydration/samples/text-fallback/_after.html new file mode 100644 index 0000000000..2d75e43c99 --- /dev/null +++ b/test/hydration/samples/text-fallback/_after.html @@ -0,0 +1,4 @@ +
+
foo override
+ default +
\ No newline at end of file diff --git a/test/hydration/samples/text-fallback/_before.html b/test/hydration/samples/text-fallback/_before.html new file mode 100644 index 0000000000..2d75e43c99 --- /dev/null +++ b/test/hydration/samples/text-fallback/_before.html @@ -0,0 +1,4 @@ +
+
foo override
+ default +
\ No newline at end of file diff --git a/test/hydration/samples/text-fallback/main.svelte b/test/hydration/samples/text-fallback/main.svelte new file mode 100644 index 0000000000..effe43254e --- /dev/null +++ b/test/hydration/samples/text-fallback/main.svelte @@ -0,0 +1,11 @@ + + + +
+ foo override +
+ + default +