diff --git a/README.md b/README.md index e0d96054df..f116e2eeb1 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ The Svelte compiler optionally takes a second argument, an object of configurati | | **Values** | **Description** | **Defaults** | |---|---|---|---| -| `format` | `'es'`, `'amd'`, `'cjs'`, `'umd'`, `'iife'`, `'eval'` | The format to output in the compiled component.
`'es'` - ES6/ES2015 module, suitable for consumption by a bundler
`'amd'` - AMD module
`'cjs'` - CommonJS module
`'iife'` - IIFE-wrapped function defining a global variable, suitable for use directly in browser
`'eval'` - standalone function, suitable for passing to `eval()` | `'es'` | +| `format` | `'es'`, `'amd'`, `'cjs'`, `'umd'`, `'iife'`, `'eval'` | The format to output in the compiled component.
`'es'` - ES6/ES2015 module, suitable for consumption by a bundler
`'amd'` - AMD module
`'cjs'` - CommonJS module
`'iife'` - IIFE-wrapped function defining a global variable, suitable for use directly in browser
`'eval'` - standalone function, suitable for passing to `eval()` | `'es'` for `generate: 'dom'`
`'cjs'` for `generate: 'ssr'` | | `generate` | `'dom'`, `'ssr'` | Whether to generate JavaScript code intended for use on the client (`'dom'`), or for use in server-side rendering (`'ssr'`). | `'dom'` | | `name` | `string` | The name of the constructor in the compiled component. | `'SvelteComponent'` | | `filename` | `string` | The filename to use in sourcemaps and compiler error and warning messages. | `'SvelteComponent.html'` | diff --git a/src/generators/dom/index.js b/src/generators/dom/index.js index 004cb6b763..f7f40054b4 100644 --- a/src/generators/dom/index.js +++ b/src/generators/dom/index.js @@ -211,8 +211,8 @@ export default function dom ( parsed, source, options, names ) { } }); if ( hasNonImportedComponent ) { - // remove the specific components which were imported, as we'll refer to them directly - Object.keys( generator.importedComponents ).forEach ( key => { + // remove the specific components that were imported, as we'll refer to them directly + Object.keys( generator.importedComponents ).forEach( key => { removeObjectKey( generator, templateProperties.components.value, key ); }); } else { diff --git a/src/parse/read/expression.js b/src/parse/read/expression.js index 61cebc9cc7..110b6af4ef 100644 --- a/src/parse/read/expression.js +++ b/src/parse/read/expression.js @@ -4,7 +4,7 @@ export default function readExpression ( parser ) { const start = parser.index; const name = parser.readUntil( /\s*}}/ ); - if ( name && /^\w+$/.test( name ) ) { + if ( name && /^[a-z]+$/.test( name ) ) { return { type: 'Identifier', start, diff --git a/src/utils/removeObjectKey.js b/src/utils/removeObjectKey.js index cbd75eb1f5..a78a5b6ab2 100644 --- a/src/utils/removeObjectKey.js +++ b/src/utils/removeObjectKey.js @@ -4,6 +4,6 @@ export default function removeObjectKey ( generator, node, key ) { const index = properties.findIndex( property => property.key.type === 'Identifier' && property.key.name === key ); if ( index === -1 ) return; const a = properties[ index ].start; - const b = index < properties.length - 1 ? properties[ index + 1 ].start : properties[ index ].end; + const b = index < properties.length - 1 ? properties[ index + 1 ].start : node.end - 1; generator.code.remove( a, b ); } diff --git a/test/generator/samples/attribute-dynamic-reserved/_config.js b/test/generator/samples/attribute-dynamic-reserved/_config.js index e14059fec0..e0e349b7bc 100644 --- a/test/generator/samples/attribute-dynamic-reserved/_config.js +++ b/test/generator/samples/attribute-dynamic-reserved/_config.js @@ -3,12 +3,12 @@ export default { class: 'foo' }, - html: `
`, + html: `
123`, test ( assert, component, target ) { component.set({ class: 'bar' }); - assert.equal( target.innerHTML, `
` ); - + assert.equal( target.innerHTML, `
123` ); + component.destroy(); } }; diff --git a/test/generator/samples/attribute-dynamic-reserved/main.html b/test/generator/samples/attribute-dynamic-reserved/main.html index 6b149d165f..47185118e2 100644 --- a/test/generator/samples/attribute-dynamic-reserved/main.html +++ b/test/generator/samples/attribute-dynamic-reserved/main.html @@ -1 +1 @@ -
\ No newline at end of file +
{{123}} diff --git a/test/generator/samples/imported-renamed-components/main.html b/test/generator/samples/imported-renamed-components/main.html index 7c25eaceab..a976830378 100644 --- a/test/generator/samples/imported-renamed-components/main.html +++ b/test/generator/samples/imported-renamed-components/main.html @@ -5,6 +5,6 @@ import ComponentTwo from './ComponentTwo.html'; export default { - components: { RenamedComponentOne: ComponentOne, RenamedComponentTwo: ComponentTwo } + components: { RenamedComponentOne: ComponentOne, RenamedComponentTwo: ComponentTwo }, };