|
|
@ -155,8 +155,6 @@ function keyed ( generator: DomGenerator, block: Block, state: State, node: Node
|
|
|
|
function ${fn} ( iteration ) {
|
|
|
|
function ${fn} ( iteration ) {
|
|
|
|
iteration.outro( function () {
|
|
|
|
iteration.outro( function () {
|
|
|
|
iteration.destroy( true );
|
|
|
|
iteration.destroy( true );
|
|
|
|
if ( iteration.next ) iteration.next.last = iteration.last;
|
|
|
|
|
|
|
|
if ( iteration.last ) iteration.last.next = iteration.next;
|
|
|
|
|
|
|
|
${lookup}[iteration.key] = null;
|
|
|
|
${lookup}[iteration.key] = null;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -179,8 +177,6 @@ function keyed ( generator: DomGenerator, block: Block, state: State, node: Node
|
|
|
|
block.builders.create.addBlock( deindent`
|
|
|
|
block.builders.create.addBlock( deindent`
|
|
|
|
function ${fn} ( iteration ) {
|
|
|
|
function ${fn} ( iteration ) {
|
|
|
|
iteration.destroy( true );
|
|
|
|
iteration.destroy( true );
|
|
|
|
if ( iteration.next && iteration.next.last === iteration ) iteration.next.last = iteration.last;
|
|
|
|
|
|
|
|
if ( iteration.last && iteration.last.next === iteration ) iteration.last.next = iteration.next;
|
|
|
|
|
|
|
|
${lookup}[iteration.key] = null;
|
|
|
|
${lookup}[iteration.key] = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
` );
|
|
|
|
` );
|
|
|
@ -204,7 +200,7 @@ function keyed ( generator: DomGenerator, block: Block, state: State, node: Node
|
|
|
|
var ${each_block_value} = ${snippet};
|
|
|
|
var ${each_block_value} = ${snippet};
|
|
|
|
|
|
|
|
|
|
|
|
var ${expected} = ${head};
|
|
|
|
var ${expected} = ${head};
|
|
|
|
var ${last};
|
|
|
|
var ${last} = null;
|
|
|
|
|
|
|
|
|
|
|
|
var discard_pile = [];
|
|
|
|
var discard_pile = [];
|
|
|
|
|
|
|
|
|
|
|
@ -220,24 +216,24 @@ function keyed ( generator: DomGenerator, block: Block, state: State, node: Node
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if ( ${iteration} ) {
|
|
|
|
if ( ${iteration} ) {
|
|
|
|
// probably a deletion
|
|
|
|
// probably a deletion
|
|
|
|
do {
|
|
|
|
|
|
|
|
|
|
|
|
while ( ${expected} && ${expected}.key !== ${key} ) {
|
|
|
|
${expected}.discard = true;
|
|
|
|
${expected}.discard = true;
|
|
|
|
discard_pile.push( ${expected} );
|
|
|
|
discard_pile.push( ${expected} );
|
|
|
|
${expected} = ${expected}.next;
|
|
|
|
${expected} = ${expected}.next;
|
|
|
|
} while ( ${expected} && ${expected}.key !== ${key} );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
${expected} = ${expected} && ${expected}.next;
|
|
|
|
${expected} = ${expected} && ${expected}.next;
|
|
|
|
${iteration}.discard = false;
|
|
|
|
${iteration}.discard = false;
|
|
|
|
${iteration}.last = ${last};
|
|
|
|
${iteration}.last = ${last};
|
|
|
|
${iteration}.next = ${expected};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
${iteration}.mount( ${parentNode}, ${expected} ? ${expected}.first : ${anchor} );
|
|
|
|
if (!${expected}) ${iteration}.mount( ${parentNode}, ${anchor} );
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// key is being inserted
|
|
|
|
// key is being inserted
|
|
|
|
${iteration} = ${lookup}[${key}] = ${create_each_block}( ${params}, ${each_block_value}, ${each_block_value}[${i}], ${i}, ${block.component}, ${key} );
|
|
|
|
${iteration} = ${lookup}[${key}] = ${create_each_block}( ${params}, ${each_block_value}, ${each_block_value}[${i}], ${i}, ${block.component}, ${key} );
|
|
|
|
${iteration}.${mountOrIntro}( ${parentNode}, ${expected}.first );
|
|
|
|
${iteration}.${mountOrIntro}( ${parentNode}, ${expected}.first );
|
|
|
|
|
|
|
|
|
|
|
|
if ( ${expected} ) ${expected}.last = ${iteration};
|
|
|
|
${expected}.last = ${iteration};
|
|
|
|
${iteration}.next = ${expected};
|
|
|
|
${iteration}.next = ${expected};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|