|
|
|
@ -17,12 +17,12 @@ function generateBlock ( generator, node, name ) {
|
|
|
|
|
counter: counter()
|
|
|
|
|
});
|
|
|
|
|
node.children.forEach( generator.visit );
|
|
|
|
|
//generator.visit( node.children );
|
|
|
|
|
generator.addRenderer( generator.current );
|
|
|
|
|
generator.pop();
|
|
|
|
|
// unset the children, to avoid them being visited again
|
|
|
|
|
node.children = [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getConditionsAndBlocks ( generator, node, _name, i = 0 ) {
|
|
|
|
|
generator.addSourcemapLocations( node.expression );
|
|
|
|
|
const name = `${_name}_${i}`;
|
|
|
|
@ -56,13 +56,12 @@ export default {
|
|
|
|
|
|
|
|
|
|
const { params, target } = generator.current;
|
|
|
|
|
const name = `ifBlock_${i}`;
|
|
|
|
|
const anchor = `${name}_anchor`;
|
|
|
|
|
const getBlock = `getBlock_${i}`;
|
|
|
|
|
const currentBlock = `currentBlock_${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`
|
|
|
|
|
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'} );
|
|
|
|
|
` );
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|