Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Mar 18, 2018
1 parent a2d09c2 commit ffa45dd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/generators/nodes/EachBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ export default class EachBlock extends Node {
block.builders.update.addBlock(deindent`
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, {
${this.contextProps.join(',\n')}
});
Expand Down
10 changes: 6 additions & 4 deletions src/shared/keyed-each.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 i = list.length;
Expand All @@ -36,7 +38,7 @@ export function updateKeyedEach(component, key, changed, key_prop, dynamic, list
keep[key] = 1;
}

var destroy = hasOutroMethod
var destroy = has_outro
? outroAndDestroyIteration
: destroyIteration;

Expand All @@ -55,7 +57,7 @@ export function updateKeyedEach(component, key, changed, key_prop, dynamic, list

var anchor;

if (hasOutroMethod) {
if (has_outro) {
var next_key = next && next.key;
var neighbour = iteration.next;
var anchor_key;
Expand All @@ -69,7 +71,7 @@ export function updateKeyedEach(component, key, changed, key_prop, dynamic, list
anchor = next && next.first;
}

iteration[iteration.i ? 'i' : 'm'](updateMountNode, anchor);
iteration[intro_method](node, anchor);

iteration.next = next;
if (next) next.last = iteration;
Expand Down

0 comments on commit ffa45dd

Please sign in to comment.