Skip to content

Commit

Permalink
DEBUG testing btakita EachBlock changes
Browse files Browse the repository at this point in the history
  • Loading branch information
talklittle authored and btakita committed Mar 17, 2018
1 parent b3fa965 commit baff9bc
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions src/generators/nodes/EachBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,14 @@ export default class EachBlock extends Node {
var ${expected} = ${head};
var ${last} = null;
var discard_pile = [];
var rendered = {};
var all = {};
var each_all = ${head};
while(each_all) {
all[each_all.key] = each_all;
each_all = each_all.next;
}
for (#i = 0; #i < ${each_block_value}.${length}; #i += 1) {
var ${key} = ${each_block_value}[#i].${this.key};
Expand All @@ -392,18 +399,21 @@ export default class EachBlock extends Node {
${expected} = ${expected}.next;
} else {
if (${iteration}) {
// probably a deletion
while (${expected} && ${expected}.key !== ${key}) {
${expected}.discard = true;
discard_pile.push(${expected});
${expected} = ${expected}.next;
};
${expected} = ${expected} && ${expected}.next;
${iteration}.discard = false;
${iteration}.last = ${last};
if (!${expected}) ${iteration}.m(${updateMountNode}, ${anchor});
var next_data = ${each_block_value}[#i+1];
var next = next_data && ${lookup}[next_data.id];
var first = ${iteration}.first;
var first_next = next && next.first;
///insertNode(first, tbody, first_next);
${updateMountNode}.insertBefore(first, first_next);
${expected} = next;
${iteration}.next = ${expected};
var prev_data = ${each_block_value}[#i-1];
var prev = prev_data && ${lookup}[prev_data.id];
if (prev) {
prev.next = ${iteration};
}
} else {
// key is being inserted
${iteration} = ${lookup}[${key}] = ${create_each_block}(#component, ${key}, ${this.each_context});
Expand All @@ -417,7 +427,6 @@ export default class EachBlock extends Node {
} else {
// we're appending from this point forward
if (${iteration}) {
${iteration}.discard = false;
${iteration}.next = null;
${iteration}.m(${updateMountNode}, ${anchor});
} else {
Expand All @@ -426,6 +435,9 @@ export default class EachBlock extends Node {
${iteration}.${mountOrIntro}(${updateMountNode}, ${anchor});
}
}
if (${iteration}) {
rendered[${iteration}.key] = ${iteration};
}
if (${last}) ${last}.next = ${iteration};
${iteration}.last = ${last};
Expand All @@ -435,7 +447,11 @@ export default class EachBlock extends Node {
if (${last}) ${last}.next = null;
${destroy}
for (var key_all in all) {
if (!rendered[key_all]) all[key_all].d();
}
${head} = ${lookup}[${each_block_value}[0] && ${each_block_value}[0].${this.key}];
`);
Expand Down

0 comments on commit baff9bc

Please sign in to comment.