|
|
@ -17,12 +17,12 @@ function generateBlock ( generator, node, name ) {
|
|
|
|
counter: counter()
|
|
|
|
counter: counter()
|
|
|
|
});
|
|
|
|
});
|
|
|
|
node.children.forEach( generator.visit );
|
|
|
|
node.children.forEach( generator.visit );
|
|
|
|
//generator.visit( node.children );
|
|
|
|
|
|
|
|
generator.addRenderer( generator.current );
|
|
|
|
generator.addRenderer( generator.current );
|
|
|
|
generator.pop();
|
|
|
|
generator.pop();
|
|
|
|
// unset the children, to avoid them being visited again
|
|
|
|
// unset the children, to avoid them being visited again
|
|
|
|
node.children = [];
|
|
|
|
node.children = [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getConditionsAndBlocks ( generator, node, _name, i = 0 ) {
|
|
|
|
function getConditionsAndBlocks ( generator, node, _name, i = 0 ) {
|
|
|
|
generator.addSourcemapLocations( node.expression );
|
|
|
|
generator.addSourcemapLocations( node.expression );
|
|
|
|
const name = `${_name}_${i}`;
|
|
|
|
const name = `${_name}_${i}`;
|
|
|
@ -56,13 +56,12 @@ export default {
|
|
|
|
|
|
|
|
|
|
|
|
const { params, target } = generator.current;
|
|
|
|
const { params, target } = generator.current;
|
|
|
|
const name = `ifBlock_${i}`;
|
|
|
|
const name = `ifBlock_${i}`;
|
|
|
|
const anchor = `${name}_anchor`;
|
|
|
|
|
|
|
|
const getBlock = `getBlock_${i}`;
|
|
|
|
const getBlock = `getBlock_${i}`;
|
|
|
|
const currentBlock = `currentBlock_${i}`;
|
|
|
|
const currentBlock = `currentBlock_${i}`;
|
|
|
|
|
|
|
|
|
|
|
|
const conditionsAndBlocks = getConditionsAndBlocks( generator, node, `renderIfBlock_${i}` );
|
|
|
|
const conditionsAndBlocks = getConditionsAndBlocks( generator, node, `renderIfBlock_${i}` );
|
|
|
|
|
|
|
|
|
|
|
|
generator.addElement( anchor, `document.createComment( ${JSON.stringify( `#if ${generator.source.slice( node.expression.start, node.expression.end )}` )} )`, true );
|
|
|
|
const anchor = generator.createAnchor( name, `#if ${generator.source.slice( node.expression.start, node.expression.end )}` );
|
|
|
|
|
|
|
|
|
|
|
|
generator.current.initStatements.push( deindent`
|
|
|
|
generator.current.initStatements.push( deindent`
|
|
|
|
function ${getBlock} ( ${params} ) {
|
|
|
|
function ${getBlock} ( ${params} ) {
|
|
|
@ -86,6 +85,9 @@ export default {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
` );
|
|
|
|
` );
|
|
|
|
|
|
|
|
|
|
|
|
generator.current.teardownStatements.push( `if ( ${name} ) ${name}.teardown( detach );` );
|
|
|
|
const isToplevel = generator.current.localElementDepth === 0;
|
|
|
|
|
|
|
|
generator.current.teardownStatements.push( deindent`
|
|
|
|
|
|
|
|
if ( ${name} ) ${name}.teardown( ${isToplevel ? 'detach' : 'false'} );
|
|
|
|
|
|
|
|
` );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|