|
|
@ -2,8 +2,21 @@ import deindent from '../utils/deindent.js';
|
|
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
export default {
|
|
|
|
enter ( generator, node ) {
|
|
|
|
enter ( generator, node ) {
|
|
|
|
generator.current.initStatements.push( deindent`
|
|
|
|
if ( generator.elementDepth > 1 ) {
|
|
|
|
${generator.current.target}.appendChild( document.createTextNode( ${JSON.stringify( node.data )} ) );
|
|
|
|
generator.current.initStatements.push( deindent`
|
|
|
|
` );
|
|
|
|
${generator.current.target}.appendChild( document.createTextNode( ${JSON.stringify( node.data )} ) );
|
|
|
|
|
|
|
|
` );
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
const name = generator.current.counter( `text` );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
generator.current.initStatements.push( deindent`
|
|
|
|
|
|
|
|
var ${name} = document.createTextNode( ${JSON.stringify( node.data )} );
|
|
|
|
|
|
|
|
${generator.current.target}.appendChild( ${name} );
|
|
|
|
|
|
|
|
` );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
generator.current.teardownStatements.push( deindent`
|
|
|
|
|
|
|
|
${name}.parentNode.removeChild( ${name} );
|
|
|
|
|
|
|
|
` );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|