Merge branch 'master' into gh-371

pull/391/head
Rich-Harris 8 years ago
commit 979ac2b87d

@ -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.<br>`'es'` - ES6/ES2015 module, suitable for consumption by a bundler<br>`'amd'` - AMD module<br>`'cjs'` - CommonJS module<br>`'iife'` - IIFE-wrapped function defining a global variable, suitable for use directly in browser<br>`'eval'` - standalone function, suitable for passing to `eval()` | `'es'` |
| `format` | `'es'`, `'amd'`, `'cjs'`, `'umd'`, `'iife'`, `'eval'` | The format to output in the compiled component.<br>`'es'` - ES6/ES2015 module, suitable for consumption by a bundler<br>`'amd'` - AMD module<br>`'cjs'` - CommonJS module<br>`'iife'` - IIFE-wrapped function defining a global variable, suitable for use directly in browser<br>`'eval'` - standalone function, suitable for passing to `eval()` | `'es'` for `generate: 'dom'`<br>`'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'` |

@ -211,7 +211,7 @@ export default function dom ( parsed, source, options, names ) {
}
});
if ( hasNonImportedComponent ) {
// remove the specific components which were imported, as we'll refer to them directly
// 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 );
});

@ -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,

@ -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 );
}

@ -3,11 +3,11 @@ export default {
class: 'foo'
},
html: `<div class="foo"></div>`,
html: `<div class="foo"></div>123`,
test ( assert, component, target ) {
component.set({ class: 'bar' });
assert.equal( target.innerHTML, `<div class="bar"></div>` );
assert.equal( target.innerHTML, `<div class="bar"></div>123` );
component.destroy();
}

@ -1 +1 @@
<div class='{{class}}'></div>
<div class='{{class}}'></div>{{123}}

@ -5,6 +5,6 @@
import ComponentTwo from './ComponentTwo.html';
export default {
components: { RenamedComponentOne: ComponentOne, RenamedComponentTwo: ComponentTwo }
components: { RenamedComponentOne: ComponentOne, RenamedComponentTwo: ComponentTwo },
};
</script>

Loading…
Cancel
Save