merge master -> rfc-1

pull/1839/head
Rich Harris 7 years ago
commit e38daf9823

@ -1,5 +1,17 @@
# Svelte changelog # Svelte changelog
## 2.15.4
* IE `classList` fix ([#1868](https://github.com/sveltejs/svelte/pull/1868))
## 2.15.3
* Don't mutate AST
## 2.15.2
* Expose `stats.props` ([#1837](https://github.com/sveltejs/svelte/issues/1837))
## 2.15.1 ## 2.15.1
* Don't throw missing store error when store is declared in component ([#1828](https://github.com/sveltejs/svelte/issues/1828)) * Don't throw missing store error when store is declared in component ([#1828](https://github.com/sveltejs/svelte/issues/1828))

@ -105,7 +105,6 @@ The Svelte compiler optionally takes a second argument, an object of configurati
| `globals` | `object`, `function` | When outputting to the `'umd'`, `'iife'` or `'eval'` formats, an object or function mapping the names of imported dependencies to the names of global variables. | `{}` | | `globals` | `object`, `function` | When outputting to the `'umd'`, `'iife'` or `'eval'` formats, an object or function mapping the names of imported dependencies to the names of global variables. | `{}` |
| `preserveComments` | `boolean` | Include comments in rendering. Currently, only applies to SSR rendering | `false` | | `preserveComments` | `boolean` | Include comments in rendering. Currently, only applies to SSR rendering | `false` |
| | | | | | | |
| `onerror` | `function` | Specify a callback for when Svelte encounters an error while compiling the component. Passed two arguments: the error object, and another function that is Svelte's default onerror handling. | (exception is thrown) |
| `onwarn` | `function` | Specify a callback for when Svelte encounters a non-fatal warning while compiling the component. Passed two arguments: the warning object, and another function that is Svelte's default onwarn handling. | (warning is logged to console) | | `onwarn` | `function` | Specify a callback for when Svelte encounters a non-fatal warning while compiling the component. Passed two arguments: the warning object, and another function that is Svelte's default onwarn handling. | (warning is logged to console) |
### Preprocessor options ### Preprocessor options

@ -97,6 +97,7 @@ export default class Stats {
}); });
return { return {
props: component.props.map(prop => prop.as),
timings, timings,
warnings: this.warnings, warnings: this.warnings,
imports, imports,

@ -70,7 +70,7 @@ export default function compile(source: string, options: CompileOptions = {}) {
stats.stop('create component'); stats.stop('create component');
if (options.generate === false) { if (options.generate === false) {
return { ast, stats: stats.render(null), js: null, css: null }; return { ast, stats: stats.render(component), js: null, css: null };
} }
const js = options.generate === 'ssr' const js = options.generate === 'ssr'

@ -250,5 +250,5 @@ export function addResizeListener(element, fn) {
} }
export function toggleClass(element, name, toggle) { export function toggleClass(element, name, toggle) {
element.classList.toggle(name, !!toggle); element.classList[toggle ? 'add' : 'remove'](name);
} }

@ -30,16 +30,15 @@ describe('stats', () => {
try { try {
result = svelte.compile(input, config.options); result = svelte.compile(input, config.options);
config.test(assert, result.stats);
if (result.stats.warnings.length || expectedWarnings.length) {
// TODO check warnings are added to stats.warnings
}
} catch (e) { } catch (e) {
error = e; error = e;
} }
config.test(assert, result.stats);
if (result.stats.warnings.length || expectedWarnings.length) {
// TODO check warnings are added to stats.warnings
}
if (error || expectedError) { if (error || expectedError) {
if (error && !expectedError) { if (error && !expectedError) {
throw error; throw error;

@ -0,0 +1,5 @@
export default {
test(assert, stats) {
assert.deepEqual(stats.props.sort(), ['cats', 'name']);
}
};

@ -0,0 +1,19 @@
<script>
export let name = 'world';
export let cats;
let foo = 1;
let bar;
$: bar = foo * 2;
</script>
<h1>Hello {name}!</h1>
<ul>
{#each cats as cat}
<li><a target="_blank" href={cat.video}>{cat.name}</a></li>
{/each}
</ul>
<p>bar: {bar}</p>
Loading…
Cancel
Save