pull/1256/head
Rich Harris 7 years ago
parent a2d09c2136
commit ffa45dd8be

@ -319,7 +319,7 @@ export default class EachBlock extends Node {
block.builders.update.addBlock(deindent` block.builders.update.addBlock(deindent`
var ${each_block_value} = ${snippet}; var ${each_block_value} = ${snippet};
@updateKeyedEach(#component, ${key}, changed, "${this.key}", ${dynamic}, ${each_block_value}, ${head}, ${lookup}, ${updateMountNode}, ${String(this.block.hasOutroMethod)}, ${create_each_block}, function(#i) { @updateKeyedEach(#component, ${key}, changed, "${this.key}", ${dynamic}, ${each_block_value}, ${head}, ${lookup}, ${updateMountNode}, ${String(this.block.hasOutroMethod)}, ${create_each_block}, "${mountOrIntro}", function(#i) {
return @assign({}, state, { return @assign({}, state, {
${this.contextProps.join(',\n')} ${this.contextProps.join(',\n')}
}); });

@ -17,7 +17,9 @@ export function outroAndDestroyIteration(iteration, lookup) {
}); });
} }
export function updateKeyedEach(component, key, changed, key_prop, dynamic, list, head, lookup, updateMountNode, hasOutroMethod, create_each_block, get_context) { // TODO is it possible to avoid mounting iterations that are
// already in the right place?
export function updateKeyedEach(component, key, changed, key_prop, dynamic, list, head, lookup, node, has_outro, create_each_block, intro_method, get_context) {
var keep = {}; var keep = {};
var i = list.length; var i = list.length;
@ -36,7 +38,7 @@ export function updateKeyedEach(component, key, changed, key_prop, dynamic, list
keep[key] = 1; keep[key] = 1;
} }
var destroy = hasOutroMethod var destroy = has_outro
? outroAndDestroyIteration ? outroAndDestroyIteration
: destroyIteration; : destroyIteration;
@ -55,7 +57,7 @@ export function updateKeyedEach(component, key, changed, key_prop, dynamic, list
var anchor; var anchor;
if (hasOutroMethod) { if (has_outro) {
var next_key = next && next.key; var next_key = next && next.key;
var neighbour = iteration.next; var neighbour = iteration.next;
var anchor_key; var anchor_key;
@ -69,7 +71,7 @@ export function updateKeyedEach(component, key, changed, key_prop, dynamic, list
anchor = next && next.first; anchor = next && next.first;
} }
iteration[iteration.i ? 'i' : 'm'](updateMountNode, anchor); iteration[intro_method](node, anchor);
iteration.next = next; iteration.next = next;
if (next) next.last = iteration; if (next) next.last = iteration;

Loading…
Cancel
Save