report changes correctly

pull/2234/head
Richard Harris 7 years ago
parent d9e08a80ad
commit d46e5bd8f7

@ -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});

@ -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}));
}
`);

@ -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} })`;
}

@ -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];

Loading…
Cancel
Save