diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d0733ef18..503fe6466c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Svelte changelog +## 1.6.6 + +* Omit text from comment anchors ([#247](https://github.com/sveltejs/svelte/issues/247)) +* Handle `xlink` attributes ([#264](https://github.com/sveltejs/svelte/issues/264)) + ## 1.6.5 * Handle `` declarations ([#255](https://github.com/sveltejs/svelte/pull/255)) diff --git a/package.json b/package.json index 40c191f029..e361ad1ad6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svelte", - "version": "1.6.5", + "version": "1.6.6", "description": "The magical disappearing UI framework", "main": "compiler/svelte.js", "files": [ 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/generators/dom/visitors/attributes/addElementAttributes.js b/src/generators/dom/visitors/attributes/addElementAttributes.js index fb549805c5..e19bf102cc 100644 --- a/src/generators/dom/visitors/attributes/addElementAttributes.js +++ b/src/generators/dom/visitors/attributes/addElementAttributes.js @@ -5,15 +5,24 @@ import flattenReference from '../../../../utils/flattenReference.js'; export default function addElementAttributes ( generator, node, local ) { node.attributes.forEach( attribute => { + const name = attribute.name; + if ( attribute.type === 'Attribute' ) { - let metadata = local.namespace ? null : attributeLookup[ attribute.name ]; + let metadata = local.namespace ? null : attributeLookup[ name ]; if ( metadata && metadata.appliesTo && !~metadata.appliesTo.indexOf( node.name ) ) metadata = null; let dynamic = false; - const isBoundOptionValue = node.name === 'option' && attribute.name === 'value'; // TODO check it's actually bound + const isBoundOptionValue = node.name === 'option' && name === 'value'; // TODO check it's actually bound const propertyName = isBoundOptionValue ? '__value' : metadata && metadata.propertyName; + const isXlink = name.slice( 0, 6 ) === 'xlink:'; + + // xlink is a special case... we could maybe extend this to generic + // namespaced attributes but I'm not sure that's applicable in + // HTML5? + const helper = isXlink ? 'setXlinkAttribute' : 'setAttribute'; + if ( attribute.value === true ) { // attributes without values, e.g.