|
|
@ -4,7 +4,7 @@ import visit from '../visit.js';
|
|
|
|
|
|
|
|
|
|
|
|
export default function visitEachBlock ( generator, block, state, node ) {
|
|
|
|
export default function visitEachBlock ( generator, block, state, node ) {
|
|
|
|
const name = generator.getUniqueName( `each_block` );
|
|
|
|
const name = generator.getUniqueName( `each_block` );
|
|
|
|
const renderer = generator.getUniqueName( `render_each_block` );
|
|
|
|
const renderer = generator.getUniqueName( `create_each_block` );
|
|
|
|
const elseName = generator.getUniqueName( `${name}_else` );
|
|
|
|
const elseName = generator.getUniqueName( `${name}_else` );
|
|
|
|
const renderElse = generator.getUniqueName( `${renderer}_else` );
|
|
|
|
const renderElse = generator.getUniqueName( `${renderer}_else` );
|
|
|
|
const i = block.getUniqueName( `i` );
|
|
|
|
const i = block.getUniqueName( `i` );
|
|
|
@ -181,27 +181,19 @@ export default function visitEachBlock ( generator, block, state, node ) {
|
|
|
|
const contextDependencies = new Map( block.contextDependencies );
|
|
|
|
const contextDependencies = new Map( block.contextDependencies );
|
|
|
|
contextDependencies.set( node.context, dependencies );
|
|
|
|
contextDependencies.set( node.context, dependencies );
|
|
|
|
|
|
|
|
|
|
|
|
const blockParams = block.params.concat( listName, context, indexName );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const getUniqueName = generator.getUniqueNameMaker( blockParams );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const childBlock = block.child({
|
|
|
|
const childBlock = block.child({
|
|
|
|
name: renderer,
|
|
|
|
name: renderer,
|
|
|
|
expression: node.expression,
|
|
|
|
expression: node.expression,
|
|
|
|
context: node.context,
|
|
|
|
context: node.context,
|
|
|
|
key: node.key,
|
|
|
|
key: node.key,
|
|
|
|
|
|
|
|
|
|
|
|
component: getUniqueName( 'component' ),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
contextDependencies,
|
|
|
|
contextDependencies,
|
|
|
|
contexts,
|
|
|
|
contexts,
|
|
|
|
indexes,
|
|
|
|
indexes,
|
|
|
|
|
|
|
|
|
|
|
|
indexNames,
|
|
|
|
indexNames,
|
|
|
|
listNames,
|
|
|
|
listNames,
|
|
|
|
params: blockParams,
|
|
|
|
params: block.params.concat( listName, context, indexName )
|
|
|
|
|
|
|
|
|
|
|
|
getUniqueName
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const childState = Object.assign( {}, state, {
|
|
|
|
const childState = Object.assign( {}, state, {
|
|
|
@ -216,8 +208,7 @@ export default function visitEachBlock ( generator, block, state, node ) {
|
|
|
|
|
|
|
|
|
|
|
|
if ( node.else ) {
|
|
|
|
if ( node.else ) {
|
|
|
|
const childBlock = block.child({
|
|
|
|
const childBlock = block.child({
|
|
|
|
name: renderElse,
|
|
|
|
name: renderElse
|
|
|
|
getUniqueName: generator.getUniqueNameMaker( block.params )
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
node.else.children.forEach( child => {
|
|
|
|
node.else.children.forEach( child => {
|
|
|
|