From a699323b20252ff1d59fb9b7456eefa0e4faa8c9 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Sun, 15 Mar 2020 05:36:46 -0400 Subject: [PATCH] tidy --- .../compile/render_dom/wrappers/Slot.ts | 18 ++++++++---------- .../component-slot-fallback-2/Inner.svelte | 4 ++-- .../component-slot-fallback-2/Outer.svelte | 6 +++--- .../component-slot-fallback-2/store.svelte | 8 ++++---- 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/compiler/compile/render_dom/wrappers/Slot.ts b/src/compiler/compile/render_dom/wrappers/Slot.ts index 10f12716a7..37b10c2ea3 100644 --- a/src/compiler/compile/render_dom/wrappers/Slot.ts +++ b/src/compiler/compile/render_dom/wrappers/Slot.ts @@ -15,7 +15,7 @@ import create_debugging_comment from './shared/create_debugging_comment'; export default class SlotWrapper extends Wrapper { node: Slot; fragment: FragmentWrapper; - fallback: Block | null; + fallback: Block | null = null; var: Identifier = { type: 'Identifier', name: 'slot' }; dependencies: Set = new Set(['$$scope']); @@ -32,7 +32,6 @@ export default class SlotWrapper extends Wrapper { this.cannot_use_innerhtml(); this.not_static_content(); - this.fallback = null; if (this.node.children.length) { this.fallback = block.child({ comment: create_debugging_comment(this.node.children[0], this.renderer.component), @@ -153,19 +152,18 @@ export default class SlotWrapper extends Wrapper { b`@transition_out(${slot_or_fallback}, #local);` ); - const dynamic_dependencies = Array.from(this.dependencies).filter(name => { + const is_dependency_dynamic = name => { if (name === '$$scope') return true; if (this.node.scope.is_let(name)) return true; const variable = renderer.component.var_lookup.get(name); return is_dynamic(variable); - }); + }; - const fallback_dynamic_dependencies = this.fallback ? Array.from(this.fallback.dependencies).filter(name => { - if (name === '$$scope') return true; - if (this.node.scope.is_let(name)) return true; - const variable = renderer.component.var_lookup.get(name); - return is_dynamic(variable); - }) : []; + const dynamic_dependencies = Array.from(this.dependencies).filter(is_dependency_dynamic); + + const fallback_dynamic_dependencies = this.fallback + ? Array.from(this.fallback.dependencies).filter(is_dependency_dynamic) + : []; const slot_update = b` if (${slot}.p && ${renderer.dirty(dynamic_dependencies)}) { diff --git a/test/runtime/samples/component-slot-fallback-2/Inner.svelte b/test/runtime/samples/component-slot-fallback-2/Inner.svelte index 4c421969b6..d1c247ad35 100644 --- a/test/runtime/samples/component-slot-fallback-2/Inner.svelte +++ b/test/runtime/samples/component-slot-fallback-2/Inner.svelte @@ -1,6 +1,6 @@ diff --git a/test/runtime/samples/component-slot-fallback-2/Outer.svelte b/test/runtime/samples/component-slot-fallback-2/Outer.svelte index 206a4295d9..1e44ba4db7 100644 --- a/test/runtime/samples/component-slot-fallback-2/Outer.svelte +++ b/test/runtime/samples/component-slot-fallback-2/Outer.svelte @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/test/runtime/samples/component-slot-fallback-2/store.svelte b/test/runtime/samples/component-slot-fallback-2/store.svelte index 86e1d6bdfd..e377aaf314 100644 --- a/test/runtime/samples/component-slot-fallback-2/store.svelte +++ b/test/runtime/samples/component-slot-fallback-2/store.svelte @@ -1,16 +1,16 @@ \ No newline at end of file