From cdb4a3568d68bbb834051473cb9485f87bc61b16 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Tue, 20 Dec 2016 23:21:28 -0500 Subject: [PATCH] use empty comments as anchors --- src/generators/dom/index.js | 4 ++-- src/generators/dom/visitors/EachBlock.js | 2 +- src/generators/dom/visitors/IfBlock.js | 2 +- src/generators/dom/visitors/YieldTag.js | 2 +- src/shared/dom.js | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/generators/dom/index.js b/src/generators/dom/index.js index 929d737700..de0c5dc496 100644 --- a/src/generators/dom/index.js +++ b/src/generators/dom/index.js @@ -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 ); } diff --git a/src/generators/dom/visitors/EachBlock.js b/src/generators/dom/visitors/EachBlock.js index 2799a421b8..700e16ef7a 100644 --- a/src/generators/dom/visitors/EachBlock.js +++ b/src/generators/dom/visitors/EachBlock.js @@ -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} = [];` ); diff --git a/src/generators/dom/visitors/IfBlock.js b/src/generators/dom/visitors/IfBlock.js index 02133e539d..5ceb42d48b 100644 --- a/src/generators/dom/visitors/IfBlock.js +++ b/src/generators/dom/visitors/IfBlock.js @@ -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} ) { diff --git a/src/generators/dom/visitors/YieldTag.js b/src/generators/dom/visitors/YieldTag.js index 5fefcd73a3..98996486c1 100644 --- a/src/generators/dom/visitors/YieldTag.js +++ b/src/generators/dom/visitors/YieldTag.js @@ -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} );` diff --git a/src/shared/dom.js b/src/shared/dom.js index 9d4231572f..4007e90289 100644 --- a/src/shared/dom.js +++ b/src/shared/dom.js @@ -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 ) {