diff --git a/CHANGELOG.md b/CHANGELOG.md index 3419e6da1f..e458527e75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # 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 * Don't throw missing store error when store is declared in component ([#1828](https://github.com/sveltejs/svelte/issues/1828)) diff --git a/README.md b/README.md index 2335d2dd18..dac940e029 100644 --- a/README.md +++ b/README.md @@ -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. | `{}` | | `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) | ### Preprocessor options diff --git a/src/Stats.ts b/src/Stats.ts index e13e5f5d15..33f651b2fa 100644 --- a/src/Stats.ts +++ b/src/Stats.ts @@ -97,6 +97,7 @@ export default class Stats { }); return { + props: component.props.map(prop => prop.as), timings, warnings: this.warnings, imports, diff --git a/src/compile/index.ts b/src/compile/index.ts index 1802d56df4..4037a6def7 100644 --- a/src/compile/index.ts +++ b/src/compile/index.ts @@ -70,7 +70,7 @@ export default function compile(source: string, options: CompileOptions = {}) { stats.stop('create component'); 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' diff --git a/src/internal/dom.js b/src/internal/dom.js index f16aea7eba..e12102d3ca 100644 --- a/src/internal/dom.js +++ b/src/internal/dom.js @@ -250,5 +250,5 @@ export function addResizeListener(element, fn) { } export function toggleClass(element, name, toggle) { - element.classList.toggle(name, !!toggle); + element.classList[toggle ? 'add' : 'remove'](name); } diff --git a/test/stats/index.js b/test/stats/index.js index b3b3fdc14c..e0b114dd9a 100644 --- a/test/stats/index.js +++ b/test/stats/index.js @@ -30,16 +30,15 @@ describe('stats', () => { try { 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) { 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) { throw error; diff --git a/test/stats/samples/props/_config.js b/test/stats/samples/props/_config.js new file mode 100644 index 0000000000..50c01e2ffb --- /dev/null +++ b/test/stats/samples/props/_config.js @@ -0,0 +1,5 @@ +export default { + test(assert, stats) { + assert.deepEqual(stats.props.sort(), ['cats', 'name']); + } +}; \ No newline at end of file diff --git a/test/stats/samples/props/input.html b/test/stats/samples/props/input.html new file mode 100644 index 0000000000..7f0c1ea4e6 --- /dev/null +++ b/test/stats/samples/props/input.html @@ -0,0 +1,19 @@ + + +

Hello {name}!

+ + + +

bar: {bar}

\ No newline at end of file