use empty comments as anchors

pull/256/head
Conduitry 8 years ago
parent 9311d1b0a6
commit cdb4a3568d

@ -98,9 +98,9 @@ class DomGenerator extends Generator {
` );
}
createAnchor ( name, description = '' ) {
createAnchor ( name ) {
this.uses.createComment = true;
const renderStatement = `createComment( ${JSON.stringify( description )} )`;
const renderStatement = `createComment()`;
this.addElement( name, renderStatement, true );
}

@ -21,7 +21,7 @@ export default {
const { dependencies, snippet } = generator.contextualise( node.expression );
const anchor = `${name}_anchor`;
generator.createAnchor( anchor, `#each ${generator.source.slice( node.expression.start, node.expression.end )}` );
generator.createAnchor( anchor );
generator.current.builders.init.addLine( `var ${name}_value = ${snippet};` );
generator.current.builders.init.addLine( `var ${iterations} = [];` );

@ -41,7 +41,7 @@ export default {
const conditionsAndBlocks = getConditionsAndBlocks( generator, node, generator.getUniqueName( `renderIfBlock` ) );
const anchor = `${name}_anchor`;
generator.createAnchor( anchor, `#if ${generator.source.slice( node.expression.start, node.expression.end )}` );
generator.createAnchor( anchor );
generator.current.builders.init.addBlock( deindent`
function ${getBlock} ( ${params} ) {

@ -1,7 +1,7 @@
export default {
enter ( generator ) {
const anchor = `yield_anchor`;
generator.createAnchor( anchor, 'yield' );
generator.createAnchor( anchor );
generator.current.builders.mount.addLine(
`component._yield && component._yield.mount( ${generator.current.target}, ${anchor} );`

@ -34,8 +34,8 @@ export function createText ( data ) {
return document.createTextNode( data );
}
export function createComment ( data ) {
return document.createComment( data );
export function createComment () {
return document.createComment( '' );
}
export function addEventListener ( node, event, handler ) {

Loading…
Cancel
Save