From aa653558d0b4eaf8023c44ad161799b376101898 Mon Sep 17 00:00:00 2001 From: Richard Harris Date: Sat, 13 Apr 2019 19:34:42 -0400 Subject: [PATCH 1/2] 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 38896b4546b6..89a575910fb5 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 000000000000..b5b69bdc97ea --- /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 000000000000..2d75e43c99ea --- /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 000000000000..2d75e43c99ea --- /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 000000000000..effe43254e64 --- /dev/null +++ b/test/hydration/samples/text-fallback/main.svelte @@ -0,0 +1,11 @@ + + + +
+ foo override +
+ + default +
From d67ffcd3d3ad94b209e427671edd707f7feb828b Mon Sep 17 00:00:00 2001 From: Richard Harris Date: Sat, 13 Apr 2019 19:40:45 -0400 Subject: [PATCH 2/2] fix hydration tests --- test/hydration/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hydration/index.js b/test/hydration/index.js index 30647cace10d..856052d69eb1 100644 --- a/test/hydration/index.js +++ b/test/hydration/index.js @@ -80,7 +80,7 @@ describe('hydration', () => { if (config.test) { config.test(assert, target, snapshot, component, window); } else { - component.destroy(); + component.$destroy(); assert.equal(target.innerHTML, ''); } } catch (err) {