From 5f296d0d330718231a56f0e9905699a8ab02fbc0 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Sat, 19 Oct 2019 10:38:08 -0400 Subject: [PATCH 1/2] produce better code for (#3631) --- .../compile/render_dom/wrappers/Slot.ts | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/compiler/compile/render_dom/wrappers/Slot.ts b/src/compiler/compile/render_dom/wrappers/Slot.ts index 1ab1b6abcb5d..fb90afab5b51 100644 --- a/src/compiler/compile/render_dom/wrappers/Slot.ts +++ b/src/compiler/compile/render_dom/wrappers/Slot.ts @@ -137,12 +137,12 @@ export default class SlotWrapper extends Wrapper { block.render_listeners(`_${slot.name}`); block.event_listeners = listeners; - if (block.chunks.create) create.push(b`if (!${slot}) { ${block.chunks.create} }`); - if (block.chunks.claim) claim.push(b`if (!${slot}) { ${block.chunks.claim} }`); - if (block.chunks.hydrate) hydrate.push(b`if (!${slot}) { ${block.chunks.hydrate} }`); - if (block.chunks.mount) mount.push(b`if (!${slot}) { ${block.chunks.mount} }`); - if (block.chunks.update) update.push(b`if (!${slot}) { ${block.chunks.update} }`); - if (block.chunks.destroy) destroy.push(b`if (!${slot}) { ${block.chunks.destroy} }`); + if (block.chunks.create.length) create.push(b`if (!${slot}) { ${block.chunks.create} }`); + if (block.chunks.claim.length) claim.push(b`if (!${slot}) { ${block.chunks.claim} }`); + if (block.chunks.hydrate.length) hydrate.push(b`if (!${slot}) { ${block.chunks.hydrate} }`); + if (block.chunks.mount.length) mount.push(b`if (!${slot}) { ${block.chunks.mount} }`); + if (block.chunks.update.length) update.push(b`if (!${slot}) { ${block.chunks.update} }`); + if (block.chunks.destroy.length) destroy.push(b`if (!${slot}) { ${block.chunks.destroy} }`); block.chunks.create = create; block.chunks.claim = claim; @@ -155,9 +155,11 @@ export default class SlotWrapper extends Wrapper { b`if (${slot}) ${slot}.c();` ); - block.chunks.claim.push( - b`if (${slot}) ${slot}.l(${parent_nodes});` - ); + if (renderer.options.hydratable) { + block.chunks.claim.push( + b`if (${slot}) ${slot}.l(${parent_nodes});` + ); + } block.chunks.mount.push(b` if (${slot}) { From adb1ea3bfdfc113631c2f73e9e1c46a8aa8e1dbb Mon Sep 17 00:00:00 2001 From: Conduitry Date: Sun, 20 Oct 2019 07:38:33 -0400 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c2611da704bc..e30f741143ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ * Use safer `HTMLElement` check before extending class ([#3608](https://github.com/sveltejs/svelte/issue/3608)) * Add `location` as a known global ([#3619](https://github.com/sveltejs/svelte/pull/3619)) * Support `{#await}` with `{:catch}` but no `{:then}` ([#3623](https://github.com/sveltejs/svelte/issues/3623)) +* Clean up dead code emitted for ``s ([#3631](https://github.com/sveltejs/svelte/issues/3631)) * Fix tracking of dependencies of compound assignments in reactive statements ([#3634](https://github.com/sveltejs/svelte/issues/3634)) * Flush changes in newly attached block when using `{#await}` ([#3660](https://github.com/sveltejs/svelte/issues/3660)) * Throw exception immediately when calling `createEventDispatcher()` after component instantiation ([#3667](https://github.com/sveltejs/svelte/pull/3667))