From 28005f1bbb9643a276bda7a1537a8319aee39fc9 Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Thu, 1 Dec 2016 09:40:39 -0500 Subject: [PATCH 01/11] dont use options.filename for original code when generating magicstring bundle (#43) --- compiler/generate/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/compiler/generate/index.js b/compiler/generate/index.js index f73b4a90b3..ba984c6263 100644 --- a/compiler/generate/index.js +++ b/compiler/generate/index.js @@ -508,7 +508,6 @@ export default function generate ( parsed, source, options ) { function addString ( str ) { compiled.addSource({ - filename: options.filename, content: new MagicString( str ) }); } From 11830952f9da559aa4a2440ee72e6a58c3798e2d Mon Sep 17 00:00:00 2001 From: Josh Duff Date: Thu, 1 Dec 2016 09:45:49 -0600 Subject: [PATCH 02/11] Adding link to Browserify transform --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 60d559cd2f..b167284c67 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ This is the Svelte compiler, which is primarily intended for authors of tooling * [svelte-cli](https://github.com/sveltejs/svelte-cli) – Command line interface for compiling components * [rollup-plugin-svelte](https://github.com/rollup/rollup-plugin-svelte) – Rollup plugin +* [sveltify](https://github.com/tehshrike/sveltify) - Browserify transform * More to come! From e2f8fedf2605389986d866d0851f50f50f7ff773 Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Thu, 1 Dec 2016 11:50:10 -0500 Subject: [PATCH 03/11] add infrastructure for sourcemap tests --- package.json | 1 + test/sourcemaps/basic/input.html | 9 +++++++++ test/sourcemaps/basic/solo | 0 test/sourcemaps/basic/test.js | 7 +++++++ test/test.js | 22 ++++++++++++++++++++++ 5 files changed, 39 insertions(+) create mode 100644 test/sourcemaps/basic/input.html create mode 100644 test/sourcemaps/basic/solo create mode 100644 test/sourcemaps/basic/test.js diff --git a/package.json b/package.json index 96bcdcf10b..9f227ccf5a 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "rollup-plugin-buble": "^0.14.0", "rollup-plugin-commonjs": "^5.0.5", "rollup-plugin-node-resolve": "^2.0.0", + "source-map": "^0.5.6", "source-map-support": "^0.4.6" }, "nyc": { diff --git a/test/sourcemaps/basic/input.html b/test/sourcemaps/basic/input.html new file mode 100644 index 0000000000..785dbb2d68 --- /dev/null +++ b/test/sourcemaps/basic/input.html @@ -0,0 +1,9 @@ +{{foo.bar.baz}} + + diff --git a/test/sourcemaps/basic/solo b/test/sourcemaps/basic/solo new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/sourcemaps/basic/test.js b/test/sourcemaps/basic/test.js new file mode 100644 index 0000000000..6c8d94128c --- /dev/null +++ b/test/sourcemaps/basic/test.js @@ -0,0 +1,7 @@ +export function test ( assert, code, map, smc, locator ) { + console.log( `code`, code ) + console.log( `map`, map ) + + let loc = locator( 'foo.bar.baz' ); + console.log( `loc`, loc ) +} diff --git a/test/test.js b/test/test.js index 9d132849e3..a956ac9852 100644 --- a/test/test.js +++ b/test/test.js @@ -5,6 +5,8 @@ import * as path from 'path'; import * as fs from 'fs'; import jsdom from 'jsdom'; import * as acorn from 'acorn'; +import { SourceMapConsumer } from 'source-map'; +import { getLocator } from 'locate-character'; import * as consoleGroup from 'console-group'; consoleGroup.install(); @@ -468,4 +470,24 @@ describe( 'svelte', () => { }); }); }); + + describe( 'sourcemaps', () => { + fs.readdirSync( 'test/sourcemaps' ).forEach( dir => { + if ( dir[0] === '.' ) return; + + const solo = exists( `test/sourcemaps/${dir}/solo` ); + + ( solo ? it.only : it )( dir, () => { + const input = fs.readFileSync( `test/sourcemaps/${dir}/input.html`, 'utf-8' ).replace( /\s+$/, '' ); + const { code, map } = svelte.compile( input ); + + const { test } = require( `./sourcemaps/${dir}/test.js` ); + + const smc = new SourceMapConsumer( map ); + const locator = getLocator( code ); + + test( assert, code, map, smc, locator ); + }); + }); + }); }); From d94858619be400ac74287745e3c3408ef8cf5929 Mon Sep 17 00:00:00 2001 From: Fabrice Weinberg Date: Thu, 1 Dec 2016 21:30:50 +0100 Subject: [PATCH 04/11] Convert entities of all text nodes --- compiler/parse/state/tag.js | 4 ++-- test/parser/convert-entities/input.html | 1 + test/parser/convert-entities/output.json | 27 ++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 test/parser/convert-entities/input.html create mode 100644 test/parser/convert-entities/output.json diff --git a/compiler/parse/state/tag.js b/compiler/parse/state/tag.js index e8c627c93a..457ed4f950 100644 --- a/compiler/parse/state/tag.js +++ b/compiler/parse/state/tag.js @@ -57,12 +57,12 @@ export default function tag ( parser ) { const lastChild = element.children[ element.children.length - 1 ]; if ( firstChild.type === 'Text' ) { - firstChild.data = trimStart( firstChild.data ); + firstChild.data = trimStart( decodeCharacterReferences( firstChild.data ) ); if ( !firstChild.data ) element.children.shift(); } if ( lastChild.type === 'Text' ) { - lastChild.data = trimEnd( lastChild.data ); + lastChild.data = trimEnd( decodeCharacterReferences( lastChild.data ) ); if ( !lastChild.data ) element.children.pop(); } } diff --git a/test/parser/convert-entities/input.html b/test/parser/convert-entities/input.html new file mode 100644 index 0000000000..bc5c086536 --- /dev/null +++ b/test/parser/convert-entities/input.html @@ -0,0 +1 @@ +

Hello & World

diff --git a/test/parser/convert-entities/output.json b/test/parser/convert-entities/output.json new file mode 100644 index 0000000000..b086da06eb --- /dev/null +++ b/test/parser/convert-entities/output.json @@ -0,0 +1,27 @@ +{ + "hash": 1090309355, + "html": { + "start": 0, + "end": 24, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 24, + "type": "Element", + "name": "p", + "attributes": [], + "children": [ + { + "start": 3, + "end": 20, + "type": "Text", + "data": "Hello & World" + } + ] + } + ] + }, + "css": null, + "js": null +} From c641144da5801dac89e6420fd57fe559d8dd4d17 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 1 Dec 2016 17:37:23 -0500 Subject: [PATCH 05/11] more sourcemap stuff --- .gitignore | 2 ++ compiler/generate/index.js | 7 +++++-- test/sourcemaps/basic/test.js | 19 ++++++++++++++----- test/test.js | 9 +++++++-- 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index b0081af1da..e3eea17ef7 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ dist .nyc_output coverage coverage.lcov +test/sourcemaps/*/output.js +test/sourcemaps/*/output.js.map diff --git a/compiler/generate/index.js b/compiler/generate/index.js index ba984c6263..7bcdd46fcc 100644 --- a/compiler/generate/index.js +++ b/compiler/generate/index.js @@ -514,13 +514,16 @@ export default function generate ( parsed, source, options ) { addString( getIntro( format, options, imports ) ); + // a filename is necessary for sourcemap generation + const filename = options.filename || 'SvelteComponent.html'; + parts.forEach( str => { const match = pattern.exec( str ); addString( str.replace( pattern, '' ) ); compiled.addSource({ - filename: options.filename, + filename, content: generator.code.snip( +match[1], +match[2] ) }); }); @@ -531,6 +534,6 @@ export default function generate ( parsed, source, options ) { return { code: compiled.toString(), - map: compiled.generateMap() + map: compiled.generateMap({ includeContent: true }) }; } diff --git a/test/sourcemaps/basic/test.js b/test/sourcemaps/basic/test.js index 6c8d94128c..295e7b2230 100644 --- a/test/sourcemaps/basic/test.js +++ b/test/sourcemaps/basic/test.js @@ -1,7 +1,16 @@ -export function test ( assert, code, map, smc, locator ) { - console.log( `code`, code ) - console.log( `map`, map ) +export function test ({ assert, smc, locateInSource, locateInGenerated }) { + const expected = locateInSource( 'foo.bar.baz' ); + const loc = locateInGenerated( 'foo.bar.baz' ); - let loc = locator( 'foo.bar.baz' ); - console.log( `loc`, loc ) + const actual = smc.originalPositionFor({ + line: loc.line + 1, + column: loc.column + }); + + assert.deepEqual( actual, { + source: 'SvelteComponent.html', + name: null, + line: expected.line, + column: expected.column + }); } diff --git a/test/test.js b/test/test.js index a956ac9852..1738c5e5ad 100644 --- a/test/test.js +++ b/test/test.js @@ -481,12 +481,17 @@ describe( 'svelte', () => { const input = fs.readFileSync( `test/sourcemaps/${dir}/input.html`, 'utf-8' ).replace( /\s+$/, '' ); const { code, map } = svelte.compile( input ); + fs.writeFileSync( `test/sourcemaps/${dir}/output.js`, `${code}\n//# sourceMappingURL=output.js.map` ); + fs.writeFileSync( `test/sourcemaps/${dir}/output.js.map`, JSON.stringify( map, null, ' ' ) ); + const { test } = require( `./sourcemaps/${dir}/test.js` ); const smc = new SourceMapConsumer( map ); - const locator = getLocator( code ); - test( assert, code, map, smc, locator ); + const locateInSource = getLocator( input ); + const locateInGenerated = getLocator( code ); + + test({ assert, code, map, smc, locateInSource, locateInGenerated }); }); }); }); From 36af0266a9d602d44d7e99dbb96f09c03b9baf10 Mon Sep 17 00:00:00 2001 From: Shinnosuke Watanabe Date: Fri, 2 Dec 2016 20:40:55 +0900 Subject: [PATCH 06/11] add links to gulp/Metalsmith plugins gulp-svelte https://github.com/shinnn/gulp-svelte https://www.npmjs.com/package/gulp-svelte metalsmith-svelte https://github.com/shinnn/metalsmith-svelte https://www.npmjs.com/package/metalsmith-svelte --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index b167284c67..16490fecf3 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ This is the Svelte compiler, which is primarily intended for authors of tooling * [svelte-cli](https://github.com/sveltejs/svelte-cli) – Command line interface for compiling components * [rollup-plugin-svelte](https://github.com/rollup/rollup-plugin-svelte) – Rollup plugin * [sveltify](https://github.com/tehshrike/sveltify) - Browserify transform +* [gulp-svelte](https://github.com/shinnn/gulp-svelte) - gulp plugin +* [metalsmith-svelte](https://github.com/shinnn/metalsmith-svelte) - Metalsmith plugin * More to come! From f8395748bedafb8234743e1be9d7808be8bf4bc3 Mon Sep 17 00:00:00 2001 From: Shinnosuke Watanabe Date: Fri, 2 Dec 2016 20:49:58 +0900 Subject: [PATCH 07/11] add .json extension to the ESLint config file According to the ESLint release note http://eslint.org/blog/2015/11/eslint-v1.10.0-released#configuration-file-formats): > We are formally deprecating use of the `.eslintrc` extensionless configuration file format in favor the format-specific versions. Don't worry, we'll still support `.eslintrc` files for a long time, but we'd like to encourage everyone to move to the new file formats as you'll get advantages such as syntax highlighting and error detection with many editors. Actually, Github doesn't highlight `.eslintrc` contents, but does well for `.eslintrc.yml`. https://github.com/stylelint/stylelint/blob/59681635dc653a8d92cefa33e113438a0df73456/.eslintrc https://github.com/stylelint/stylelint/blob/72e007a88fc765194fc429467cade14680cdb0ac/.eslintrc.yml --- .eslintrc => .eslintrc.json | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .eslintrc => .eslintrc.json (100%) diff --git a/.eslintrc b/.eslintrc.json similarity index 100% rename from .eslintrc rename to .eslintrc.json From 792d73def83c44499e67d4b675a303898048c81c Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Fri, 2 Dec 2016 11:26:16 -0500 Subject: [PATCH 08/11] upgrade magic-string, fix sourcemaps --- compiler/generate/index.js | 25 +++++++++++-------- .../attributes/addComponentAttributes.js | 2 +- .../attributes/addElementAttributes.js | 2 +- package.json | 2 +- test/sourcemaps/basic/input.html | 8 ------ test/sourcemaps/basic/solo | 0 test/sourcemaps/basic/test.js | 24 +++++++++++++++--- test/sourcemaps/script/input.html | 9 +++++++ test/sourcemaps/script/test.js | 16 ++++++++++++ 9 files changed, 63 insertions(+), 25 deletions(-) delete mode 100644 test/sourcemaps/basic/solo create mode 100644 test/sourcemaps/script/input.html create mode 100644 test/sourcemaps/script/test.js diff --git a/compiler/generate/index.js b/compiler/generate/index.js index 7bcdd46fcc..347d7062cf 100644 --- a/compiler/generate/index.js +++ b/compiler/generate/index.js @@ -86,7 +86,7 @@ export default function generate ( parsed, source, options ) { const { name } = flattenReference( node ); if ( parent && parent.type === 'CallExpression' && node === parent.callee ) { - if ( generator.helpers[ name ] ) generator.code.insertRight( node.start, `template.helpers.` ); + if ( generator.helpers[ name ] ) generator.code.prependRight( node.start, `template.helpers.` ); return; } @@ -102,7 +102,7 @@ export default function generate ( parsed, source, options ) { if ( !~usedContexts.indexOf( context ) ) usedContexts.push( context ); } else { dependencies.push( node.name ); - generator.code.insertRight( node.start, `root.` ); + generator.code.prependRight( node.start, `root.` ); if ( !~usedContexts.indexOf( 'root' ) ) usedContexts.push( 'root' ); } @@ -204,19 +204,19 @@ export default function generate ( parsed, source, options ) { while ( /\s/.test( source[ i - 1 ] ) ) i--; const indentation = source.slice( i, defaultExport.start ); - generator.code.insertLeft( finalNode.end, `\n\n${indentation}return template;` ); + generator.code.appendLeft( finalNode.end, `\n\n${indentation}return template;` ); } defaultExport.declaration.properties.forEach( prop => { templateProperties[ prop.key.name ] = prop.value; }); - generator.code.insertRight( parsed.js.content.start, 'var template = (function () {' ); + generator.code.prependRight( parsed.js.content.start, 'var template = (function () {' ); } else { - generator.code.insertRight( parsed.js.content.start, '(function () {' ); + generator.code.prependRight( parsed.js.content.start, '(function () {' ); } - generator.code.insertLeft( parsed.js.content.end, '}());' ); + generator.code.appendLeft( parsed.js.content.end, '}());' ); [ 'helpers', 'events', 'components' ].forEach( key => { if ( templateProperties[ key ] ) { @@ -512,24 +512,27 @@ export default function generate ( parsed, source, options ) { }); } - addString( getIntro( format, options, imports ) ); + const intro = getIntro( format, options, imports ); + if ( intro ) addString( intro ); // a filename is necessary for sourcemap generation const filename = options.filename || 'SvelteComponent.html'; parts.forEach( str => { + const chunk = str.replace( pattern, '' ); + if ( chunk ) addString( chunk ); + const match = pattern.exec( str ); - addString( str.replace( pattern, '' ) ); + const snippet = generator.code.snip( +match[1], +match[2] ); compiled.addSource({ filename, - content: generator.code.snip( +match[1], +match[2] ) + content: snippet }); }); - compiled.append( finalChunk ); - + addString( finalChunk ); addString( '\n\n' + getOutro( format, constructorName, options, imports ) ); return { diff --git a/compiler/generate/visitors/attributes/addComponentAttributes.js b/compiler/generate/visitors/attributes/addComponentAttributes.js index 9995352dc8..47609e9c81 100644 --- a/compiler/generate/visitors/attributes/addComponentAttributes.js +++ b/compiler/generate/visitors/attributes/addComponentAttributes.js @@ -80,7 +80,7 @@ export default function addComponentAttributes ( generator, node, local ) { else if ( attribute.type === 'EventHandler' ) { // TODO verify that it's a valid callee (i.e. built-in or declared method) generator.addSourcemapLocations( attribute.expression ); - generator.code.insertRight( attribute.expression.start, 'component.' ); + generator.code.prependRight( attribute.expression.start, 'component.' ); const usedContexts = new Set(); attribute.expression.arguments.forEach( arg => { diff --git a/compiler/generate/visitors/attributes/addElementAttributes.js b/compiler/generate/visitors/attributes/addElementAttributes.js index 8637266ffd..6f372b24ee 100644 --- a/compiler/generate/visitors/attributes/addElementAttributes.js +++ b/compiler/generate/visitors/attributes/addElementAttributes.js @@ -116,7 +116,7 @@ export default function addElementAttributes ( generator, node, local ) { else if ( attribute.type === 'EventHandler' ) { // TODO verify that it's a valid callee (i.e. built-in or declared method) generator.addSourcemapLocations( attribute.expression ); - generator.code.insertRight( attribute.expression.start, 'component.' ); + generator.code.prependRight( attribute.expression.start, 'component.' ); const usedContexts = new Set(); attribute.expression.arguments.forEach( arg => { diff --git a/package.json b/package.json index 9f227ccf5a..fdd79c6f04 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "fuzzyset.js": "0.0.1", "jsdom": "^9.8.3", "locate-character": "^2.0.0", - "magic-string": "^0.16.0", + "magic-string": "^0.19.0", "mocha": "^3.1.2", "node-resolve": "^1.3.3", "nyc": "^9.0.1", diff --git a/test/sourcemaps/basic/input.html b/test/sourcemaps/basic/input.html index 785dbb2d68..ed83093fa9 100644 --- a/test/sourcemaps/basic/input.html +++ b/test/sourcemaps/basic/input.html @@ -1,9 +1 @@ {{foo.bar.baz}} - - diff --git a/test/sourcemaps/basic/solo b/test/sourcemaps/basic/solo deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/sourcemaps/basic/test.js b/test/sourcemaps/basic/test.js index 295e7b2230..b169b04f7a 100644 --- a/test/sourcemaps/basic/test.js +++ b/test/sourcemaps/basic/test.js @@ -1,8 +1,26 @@ export function test ({ assert, smc, locateInSource, locateInGenerated }) { const expected = locateInSource( 'foo.bar.baz' ); - const loc = locateInGenerated( 'foo.bar.baz' ); - const actual = smc.originalPositionFor({ + let loc; + let actual; + + loc = locateInGenerated( 'foo.bar.baz' ); + + actual = smc.originalPositionFor({ + line: loc.line + 1, + column: loc.column + }); + + assert.deepEqual( actual, { + source: 'SvelteComponent.html', + name: null, + line: expected.line + 1, + column: expected.column + }); + + loc = locateInGenerated( 'foo.bar.baz', loc.character + 1 ); + + actual = smc.originalPositionFor({ line: loc.line + 1, column: loc.column }); @@ -10,7 +28,7 @@ export function test ({ assert, smc, locateInSource, locateInGenerated }) { assert.deepEqual( actual, { source: 'SvelteComponent.html', name: null, - line: expected.line, + line: expected.line + 1, column: expected.column }); } diff --git a/test/sourcemaps/script/input.html b/test/sourcemaps/script/input.html new file mode 100644 index 0000000000..c4dc11d3a0 --- /dev/null +++ b/test/sourcemaps/script/input.html @@ -0,0 +1,9 @@ +
+ + diff --git a/test/sourcemaps/script/test.js b/test/sourcemaps/script/test.js new file mode 100644 index 0000000000..6b14b91a9d --- /dev/null +++ b/test/sourcemaps/script/test.js @@ -0,0 +1,16 @@ +export function test ({ assert, smc, locateInSource, locateInGenerated }) { + const expected = locateInSource( '42' ); + const loc = locateInGenerated( '42' ); + + const actual = smc.originalPositionFor({ + line: loc.line + 1, + column: loc.column + }); + + assert.deepEqual( actual, { + source: 'SvelteComponent.html', + name: null, + line: expected.line + 1, + column: expected.column + }); +} From 7c9f8307677bf8ec8dce3d92ab75e4b3f57c67de Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Fri, 2 Dec 2016 11:36:05 -0500 Subject: [PATCH 09/11] -> v1.0.6 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a17bf19821..62f7d296f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Svelte changelog +## 1.0.6 + +* Generate useful sourcemaps ([#60](https://github.com/sveltejs/svelte/issues/60)) + ## 1.0.5 * Ensure compiler only generates ES5 code ([#75](https://github.com/sveltejs/svelte/issues/75)) diff --git a/package.json b/package.json index fdd79c6f04..788c8951e1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svelte", - "version": "1.0.5", + "version": "1.0.6", "description": "The magical disappearing UI framework", "main": "dist/svelte.js", "files": [ From d5defef58442995b1007701b3eb46589f778a67f Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Fri, 2 Dec 2016 11:44:00 -0500 Subject: [PATCH 10/11] use decodeCharacterReferences in text.js, not tag.js --- compiler/parse/state/tag.js | 4 +- compiler/parse/state/text.js | 4 +- .../convert-entities-in-element/input.html | 1 + .../convert-entities-in-element/output.json | 26 ++++++++++++ test/parser/convert-entities/input.html | 2 +- test/parser/convert-entities/output.json | 40 +++++++------------ 6 files changed, 48 insertions(+), 29 deletions(-) create mode 100644 test/parser/convert-entities-in-element/input.html create mode 100644 test/parser/convert-entities-in-element/output.json diff --git a/compiler/parse/state/tag.js b/compiler/parse/state/tag.js index 457ed4f950..e8c627c93a 100644 --- a/compiler/parse/state/tag.js +++ b/compiler/parse/state/tag.js @@ -57,12 +57,12 @@ export default function tag ( parser ) { const lastChild = element.children[ element.children.length - 1 ]; if ( firstChild.type === 'Text' ) { - firstChild.data = trimStart( decodeCharacterReferences( firstChild.data ) ); + firstChild.data = trimStart( firstChild.data ); if ( !firstChild.data ) element.children.shift(); } if ( lastChild.type === 'Text' ) { - lastChild.data = trimEnd( decodeCharacterReferences( lastChild.data ) ); + lastChild.data = trimEnd( lastChild.data ); if ( !lastChild.data ) element.children.pop(); } } diff --git a/compiler/parse/state/text.js b/compiler/parse/state/text.js index 8a0c9046a7..ee42dd25e3 100644 --- a/compiler/parse/state/text.js +++ b/compiler/parse/state/text.js @@ -1,3 +1,5 @@ +import { decodeCharacterReferences } from '../utils/html.js'; + export default function text ( parser ) { const start = parser.index; @@ -11,7 +13,7 @@ export default function text ( parser ) { start, end: parser.index, type: 'Text', - data + data: decodeCharacterReferences( data ) }); return null; diff --git a/test/parser/convert-entities-in-element/input.html b/test/parser/convert-entities-in-element/input.html new file mode 100644 index 0000000000..bc5c086536 --- /dev/null +++ b/test/parser/convert-entities-in-element/input.html @@ -0,0 +1 @@ +

Hello & World

diff --git a/test/parser/convert-entities-in-element/output.json b/test/parser/convert-entities-in-element/output.json new file mode 100644 index 0000000000..4f39e826e7 --- /dev/null +++ b/test/parser/convert-entities-in-element/output.json @@ -0,0 +1,26 @@ +{ + "html": { + "start": 0, + "end": 24, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 24, + "type": "Element", + "name": "p", + "attributes": [], + "children": [ + { + "start": 3, + "end": 20, + "type": "Text", + "data": "Hello & World" + } + ] + } + ] + }, + "css": null, + "js": null +} diff --git a/test/parser/convert-entities/input.html b/test/parser/convert-entities/input.html index bc5c086536..e25e3214f2 100644 --- a/test/parser/convert-entities/input.html +++ b/test/parser/convert-entities/input.html @@ -1 +1 @@ -

Hello & World

+Hello & World diff --git a/test/parser/convert-entities/output.json b/test/parser/convert-entities/output.json index b086da06eb..f5124865c8 100644 --- a/test/parser/convert-entities/output.json +++ b/test/parser/convert-entities/output.json @@ -1,27 +1,17 @@ { - "hash": 1090309355, - "html": { - "start": 0, - "end": 24, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 24, - "type": "Element", - "name": "p", - "attributes": [], - "children": [ - { - "start": 3, - "end": 20, - "type": "Text", - "data": "Hello & World" - } - ] - } - ] - }, - "css": null, - "js": null + "html": { + "start": 0, + "end": 17, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 17, + "type": "Text", + "data": "Hello & World" + } + ] + }, + "css": null, + "js": null } From 7e99b52c1094ee076f234cb6a63dbdbff5ac8568 Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Fri, 2 Dec 2016 11:48:41 -0500 Subject: [PATCH 11/11] -> v1.0.7 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62f7d296f1..041d9912bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Svelte changelog +## 1.0.7 + +* Correctly escape HTML entities ([#85](https://github.com/sveltejs/svelte/issues/85)) + ## 1.0.6 * Generate useful sourcemaps ([#60](https://github.com/sveltejs/svelte/issues/60)) diff --git a/package.json b/package.json index 788c8951e1..418539cc89 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svelte", - "version": "1.0.6", + "version": "1.0.7", "description": "The magical disappearing UI framework", "main": "dist/svelte.js", "files": [