|
|
|
@ -2,8 +2,21 @@ import deindent from '../utils/deindent.js';
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
enter ( generator, node ) {
|
|
|
|
|
generator.current.initStatements.push( deindent`
|
|
|
|
|
${generator.current.target}.appendChild( document.createTextNode( ${JSON.stringify( node.data )} ) );
|
|
|
|
|
` );
|
|
|
|
|
if ( generator.elementDepth > 1 ) {
|
|
|
|
|
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} );
|
|
|
|
|
` );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|