From d46e5bd8f77b4d440ea81de5d57b72c075426c0a Mon Sep 17 00:00:00 2001 From: Richard Harris Date: Sat, 16 Mar 2019 14:44:17 -0400 Subject: [PATCH] report changes correctly --- .../render-dom/wrappers/InlineComponent/index.ts | 1 - src/compile/render-dom/wrappers/Slot.ts | 2 +- .../render-dom/wrappers/shared/get_context_merger.ts | 10 +++++++++- src/internal/utils.js | 6 ++++++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/compile/render-dom/wrappers/InlineComponent/index.ts b/src/compile/render-dom/wrappers/InlineComponent/index.ts index 979b09d612..faf9d91233 100644 --- a/src/compile/render-dom/wrappers/InlineComponent/index.ts +++ b/src/compile/render-dom/wrappers/InlineComponent/index.ts @@ -492,7 +492,6 @@ export default class InlineComponentWrapper extends Wrapper { `); if (updates.length) { - console.log({ updates }); block.builders.update.addBlock(deindent` ${updates} ${name}.$set(${name_changes}); diff --git a/src/compile/render-dom/wrappers/Slot.ts b/src/compile/render-dom/wrappers/Slot.ts index 440590239d..31ca05b0df 100644 --- a/src/compile/render-dom/wrappers/Slot.ts +++ b/src/compile/render-dom/wrappers/Slot.ts @@ -142,7 +142,7 @@ export default class SlotWrapper extends Wrapper { block.builders.update.addBlock(deindent` if (${slot} && ${update_conditions}) { - ${slot}.p(@assign(@assign({}, ${get_slot_changes}(changed)), ctx.$$scope.changed), @get_slot_context(${slot_definition}, ctx, ${get_slot_context})); + ${slot}.p(@get_slot_changes(${slot_definition}, ctx, changed, ${get_slot_changes}), @get_slot_context(${slot_definition}, ctx, ${get_slot_context})); } `); diff --git a/src/compile/render-dom/wrappers/shared/get_context_merger.ts b/src/compile/render-dom/wrappers/shared/get_context_merger.ts index bbd14ec87d..fafdd28951 100644 --- a/src/compile/render-dom/wrappers/shared/get_context_merger.ts +++ b/src/compile/render-dom/wrappers/shared/get_context_merger.ts @@ -4,7 +4,15 @@ export function get_context_merger(lets: Let[]) { if (lets.length === 0) return null; const input = lets.map(l => l.value ? `${l.name}: ${l.value}` : l.name).join(', '); - const output = lets.map(l => l.names.join(', ')).join(', '); + + const names = new Set(); + lets.forEach(l => { + l.names.forEach(name => { + names.add(name); + }); + }); + + const output = Array.from(names).join(', '); return `({ ${input} }) => ({ ${output} })`; } \ No newline at end of file diff --git a/src/internal/utils.js b/src/internal/utils.js index d6b1bb6380..519d1b64d4 100644 --- a/src/internal/utils.js +++ b/src/internal/utils.js @@ -64,6 +64,12 @@ export function get_slot_context(definition, ctx, fn) { : ctx.$$scope.ctx; } +export function get_slot_changes(definition, ctx, changed, fn) { + return definition[1] + ? assign({}, assign(ctx.$$scope.changed || {}, definition[1](fn ? fn(changed) : {}))) + : ctx.$$scope.changed || {}; +} + export function exclude_internal_props(props) { const result = {}; for (const k in props) if (k[0] !== '$') result[k] = props[k];