diff --git a/.mocharc.coverage.js b/.mocharc.coverage.js deleted file mode 100644 index 91c93518ca..0000000000 --- a/.mocharc.coverage.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = Object.assign( - {}, - require('./mocharc.js'), - { - fullTrace: true, - require: [ - 'source-map-support/register' - ] - } -); diff --git a/.mocharc.js b/.mocharc.js index 6159fd937f..de41cdd353 100644 --- a/.mocharc.js +++ b/.mocharc.js @@ -3,3 +3,13 @@ module.exports = { 'test/test.js' ] }; + +// add coverage options when running 'npx c8 mocha' +if (process.env.NODE_V8_COVERAGE) { + Object.assign(module.exports, { + fullTrace: true, + require: [ + 'source-map-support/register' + ] + }); +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 21a9441c41..d74279c2e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Svelte changelog +## Unreleased + +* Support `_` as numeric separator ([#5407](https://github.com/sveltejs/svelte/issues/5407)) +* Fix assignments to properties on store values ([#5412](https://github.com/sveltejs/svelte/issues/5412)) +* Support `import.meta` in template expressions ([#5422](https://github.com/sveltejs/svelte/issues/5422)) + +## 3.25.1 + +* Fix specificity of certain styles involving a child selector ([#4795](https://github.com/sveltejs/svelte/issues/4795)) +* Fix transitions that are parameterised with stores ([#5244](https://github.com/sveltejs/svelte/issues/5244)) +* Fix scoping of styles involving child selector and `*` ([#5370](https://github.com/sveltejs/svelte/issues/5370)) +* Fix destructuring which reassigns stores ([#5388](https://github.com/sveltejs/svelte/issues/5388)) +* Fix `{#await}`s with no `{:catch}` getting stuck unresolved if the promise rejects ([#5401](https://github.com/sveltejs/svelte/issues/5401)) + ## 3.25.0 * Use `null` rather than `undefined` for coerced bound value of `` ([#1701](https://github.com/sveltejs/svelte/issues/1701)) diff --git a/package-lock.json b/package-lock.json index 34189b3f63..2e2a95b362 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "svelte", - "version": "3.25.0", + "version": "3.25.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -315,9 +315,9 @@ "dev": true }, "acorn": { - "version": "7.3.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.3.1.tgz", - "integrity": "sha512-tLc0wSnatxAQHVHUapaHdz72pi9KUyHjq5KyHjGg9Y8Ifdc79pTh2XvI6I1/chZbnM7QtNKzh66ooDogPZSleA==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz", + "integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==", "dev": true }, "acorn-globals": { diff --git a/package.json b/package.json index 59f35dfa80..7ebb41fdfb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svelte", - "version": "3.25.0", + "version": "3.25.1", "description": "Cybernetically enhanced web apps", "module": "index.mjs", "main": "index", @@ -23,10 +23,10 @@ }, "types": "types/runtime/index.d.ts", "scripts": { - "test": "mocha --config .mocharc.js", + "test": "mocha", "test:unit": "mocha --require sucrase/register --recursive src/**/__test__.ts", - "quicktest": "mocha --config .mocharc.js", - "precoverage": "c8 mocha --config .mocharc.coverage.js", + "quicktest": "mocha", + "precoverage": "c8 mocha", "coverage": "c8 report --reporter=text-lcov > coverage.lcov && c8 report --reporter=html", "codecov": "codecov", "precodecov": "npm run coverage", @@ -68,7 +68,7 @@ "@types/node": "^8.10.53", "@typescript-eslint/eslint-plugin": "^3.0.2", "@typescript-eslint/parser": "^3.0.2", - "acorn": "^7.3.1", + "acorn": "^7.4.0", "agadoo": "^1.1.0", "c8": "^5.0.1", "code-red": "^0.1.3", diff --git a/site/content/faq/200-are-there-any-video-courses.md b/site/content/faq/200-are-there-any-video-courses.md index 1a70cdfcf5..97e0e9d808 100644 --- a/site/content/faq/200-are-there-any-video-courses.md +++ b/site/content/faq/200-are-there-any-video-courses.md @@ -6,9 +6,9 @@ Rich Harris, the creator of Svelte, taught a course: - [Frontend Masters](https://frontendmasters.com/courses/svelte/) -There are also a couple of third-party courses: +There are also a number of third-party courses: -- [Egghead](https://egghead.io/playlists/getting-started-with-svelte-3-05a8541a) -- [Udemy](https://www.udemy.com/sveltejs-the-complete-guide/) +- [Egghead](https://egghead.io/browse/frameworks/svelte) +- [Udemy](https://www.udemy.com/courses/search/?q=sveltejs+svelte) Note that Udemy very frequently has discounts over 90%. diff --git a/site/content/faq/250-are-there-any-books.md b/site/content/faq/250-are-there-any-books.md new file mode 100644 index 0000000000..80870428ec --- /dev/null +++ b/site/content/faq/250-are-there-any-books.md @@ -0,0 +1,9 @@ +--- +question: Are there any books? +--- + +There are a few books: + +- [Svelte Handbook](https://flaviocopes.com/page/download-svelte-handbook/) by Flavio Copes +- [Svelte 3 Up and Running](https://www.amazon.com/dp/B08D6T6BKS/) by Alessandro Segala +- [Svelte and Sapper in Action](https://www.manning.com/books/svelte-and-sapper-in-action) by R. Mark Volkmann diff --git a/site/src/routes/_layout.svelte b/site/src/routes/_layout.svelte index 07445de0a0..55f4861880 100644 --- a/site/src/routes/_layout.svelte +++ b/site/src/routes/_layout.svelte @@ -62,7 +62,6 @@ +
+
+ +
+
\ No newline at end of file diff --git a/test/css/samples/unused-selector-child-combinator/_config.js b/test/css/samples/unused-selector-child-combinator/_config.js new file mode 100644 index 0000000000..becf382147 --- /dev/null +++ b/test/css/samples/unused-selector-child-combinator/_config.js @@ -0,0 +1,45 @@ +export default { + warnings: [ + { + code: "css-unused-selector", + message: 'Unused CSS selector "article > *"', + frame: ` + 1: + +
+

+ Svelte REPLs are svelte. +

+
\ No newline at end of file diff --git a/test/js/samples/import-meta/expected.js b/test/js/samples/import-meta/expected.js new file mode 100644 index 0000000000..ba77398321 --- /dev/null +++ b/test/js/samples/import-meta/expected.js @@ -0,0 +1,53 @@ +/* generated by Svelte vX.Y.Z */ +import { + SvelteComponent, + detach, + init, + insert, + noop, + safe_not_equal, + space, + text +} from "svelte/internal"; + +function create_fragment(ctx) { + let t0; + let t1; + let t2_value = import.meta.url + ""; + let t2; + + return { + c() { + t0 = text(/*url*/ ctx[0]); + t1 = space(); + t2 = text(t2_value); + }, + m(target, anchor) { + insert(target, t0, anchor); + insert(target, t1, anchor); + insert(target, t2, anchor); + }, + p: noop, + i: noop, + o: noop, + d(detaching) { + if (detaching) detach(t0); + if (detaching) detach(t1); + if (detaching) detach(t2); + } + }; +} + +function instance($$self) { + const url = import.meta.url; + return [url]; +} + +class Component extends SvelteComponent { + constructor(options) { + super(); + init(this, options, instance, create_fragment, safe_not_equal, {}); + } +} + +export default Component; \ No newline at end of file diff --git a/test/js/samples/import-meta/input.svelte b/test/js/samples/import-meta/input.svelte new file mode 100644 index 0000000000..a5ce32dd77 --- /dev/null +++ b/test/js/samples/import-meta/input.svelte @@ -0,0 +1,6 @@ + + +{url} +{import.meta.url} diff --git a/test/runtime/samples/await-without-catch/_config.js b/test/runtime/samples/await-without-catch/_config.js index 2030ed7949..1b7da5c0be 100644 --- a/test/runtime/samples/await-without-catch/_config.js +++ b/test/runtime/samples/await-without-catch/_config.js @@ -39,6 +39,7 @@ export default { }) .catch((err) => { assert.equal(err.message, 'this error should be thrown'); + assert.htmlEqual(target.innerHTML, ''); }); } }; \ No newline at end of file diff --git a/test/runtime/samples/numeric-seperator/_config.js b/test/runtime/samples/numeric-seperator/_config.js new file mode 100644 index 0000000000..bc6d7c04f3 --- /dev/null +++ b/test/runtime/samples/numeric-seperator/_config.js @@ -0,0 +1,3 @@ +export default { + html: `2048 2048` +}; diff --git a/test/runtime/samples/numeric-seperator/main.svelte b/test/runtime/samples/numeric-seperator/main.svelte new file mode 100644 index 0000000000..e491b8a107 --- /dev/null +++ b/test/runtime/samples/numeric-seperator/main.svelte @@ -0,0 +1,5 @@ + + +{num} {2_048} \ No newline at end of file diff --git a/test/runtime/samples/reactive-assignment-in-complex-declaration-with-store/_config.js b/test/runtime/samples/reactive-assignment-in-complex-declaration-with-store/_config.js new file mode 100644 index 0000000000..e74cea70fe --- /dev/null +++ b/test/runtime/samples/reactive-assignment-in-complex-declaration-with-store/_config.js @@ -0,0 +1,3 @@ +export default { + html: `

2 2 xxx 5 6

` +}; \ No newline at end of file diff --git a/test/runtime/samples/reactive-assignment-in-complex-declaration-with-store/main.svelte b/test/runtime/samples/reactive-assignment-in-complex-declaration-with-store/main.svelte new file mode 100644 index 0000000000..5ad442e1da --- /dev/null +++ b/test/runtime/samples/reactive-assignment-in-complex-declaration-with-store/main.svelte @@ -0,0 +1,16 @@ + + +

{foo} {$eid} {u.name} {v} {$w}

diff --git a/test/runtime/samples/reactive-assignment-in-declaration/main.svelte b/test/runtime/samples/reactive-assignment-in-declaration/main.svelte index 8aa05964dd..edac4427bb 100644 --- a/test/runtime/samples/reactive-assignment-in-declaration/main.svelte +++ b/test/runtime/samples/reactive-assignment-in-declaration/main.svelte @@ -1,6 +1,9 @@

{foo} {bar}

diff --git a/test/runtime/samples/reactive-assignment-in-for-loop-head/main.svelte b/test/runtime/samples/reactive-assignment-in-for-loop-head/main.svelte index 1c24f364ac..b007f6fe8b 100644 --- a/test/runtime/samples/reactive-assignment-in-for-loop-head/main.svelte +++ b/test/runtime/samples/reactive-assignment-in-for-loop-head/main.svelte @@ -1,9 +1,14 @@

{foo1} {foo2}

diff --git a/test/runtime/samples/store-assignment-updates-property/_config.js b/test/runtime/samples/store-assignment-updates-property/_config.js new file mode 100644 index 0000000000..65df38f9e4 --- /dev/null +++ b/test/runtime/samples/store-assignment-updates-property/_config.js @@ -0,0 +1,32 @@ +export default { + html: ` +

a: {"foo":3,"bar":2}

+

b: {"foo":3}

+ + + `, + skip_if_ssr: true, + + async test({ assert, component, target, window }) { + const [btn1, btn2] = target.querySelectorAll('button'); + const click = new window.MouseEvent('click'); + + await btn1.dispatchEvent(click); + + assert.htmlEqual(target.innerHTML, ` +

a: {"foo":4,"bar":2}

+

b: {"foo":4,"baz":0}

+ + + `); + + await btn2.dispatchEvent(click); + + assert.htmlEqual(target.innerHTML, ` +

a: {"foo":5,"bar":2}

+

b: {"foo":5,"qux":0}

+ + + `); + } +}; \ No newline at end of file diff --git a/test/runtime/samples/store-assignment-updates-property/main.svelte b/test/runtime/samples/store-assignment-updates-property/main.svelte new file mode 100644 index 0000000000..c3196a278c --- /dev/null +++ b/test/runtime/samples/store-assignment-updates-property/main.svelte @@ -0,0 +1,24 @@ + + +

a: {JSON.stringify($a)}

+

b: {JSON.stringify($b)}

+ +