create start anchors for each-blocks that need them

pull/568/head
Rich-Harris 8 years ago
parent b91ae93cae
commit 08f7321d69

@ -5,10 +5,13 @@ export default class Block {
constructor ( options ) {
this.generator = options.generator;
this.name = options.name;
this.key = options.key;
this.expression = options.expression;
this.context = options.context;
// for keyed each blocks
this.key = options.key;
this.first = null;
this.contexts = options.contexts;
this.indexes = options.indexes;
this.contextDependencies = options.contextDependencies;
@ -155,6 +158,10 @@ export default class Block {
properties.addBlock( `key: ${localKey},` );
}
if ( this.first ) {
properties.addBlock( `first: ${this.first},` );
}
if ( this.builders.mount.isEmpty() ) {
properties.addBlock( `mount: ${this.generator.helper( 'noop' )},` );
} else {

@ -118,6 +118,13 @@ function keyed ( generator, block, state, node, snippet, { each_block, create_ea
const iteration = block.getUniqueName( `${each_block}_iteration` );
const _iterations = block.getUniqueName( `_${each_block}_iterations` );
if ( node.children[0] && node.children[0].type === 'Element' ) { // TODO or text/tag/raw
node._block.first = node.children[0]._state.parentNode; // TODO this is highly confusing
} else {
node._block.first = node._block.getUniqueName( 'first' );
node._block.addElement( node._block.first, `${generator.helper( 'createComment' )}()`, null, true );
}
block.builders.create.addBlock( deindent`
var ${lookup} = Object.create( null );

Loading…
Cancel
Save