From 455a5cc754cbdf605630aceb8dab6bb1281d8a95 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Thu, 23 Jan 2020 10:06:42 -0500 Subject: [PATCH 01/16] fix hydration of (#4311) --- CHANGELOG.md | 1 + src/compiler/compile/render_ssr/handlers/Title.ts | 6 +----- .../samples/head-meta-hydrate-duplicate/_before_head.html | 2 +- .../samples/head-meta-hydrate-duplicate/_expected-head.html | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5838dcac80..70a4abab9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * Fix updating a `<slot>` inside an `{#if}` or other block ([#4292](https://github.com/sveltejs/svelte/issues/4292)) * Fix using RxJS observables in `derived` stores ([#4298](https://github.com/sveltejs/svelte/issues/4298)) * Add dev mode check to disallow duplicate keys in a keyed `{#each}` ([#4301](https://github.com/sveltejs/svelte/issues/4301)) +* Fix hydration of `<title>` when starting from SSR-generated code with `hydratable: true` ([#4310](https://github.com/sveltejs/svelte/issues/4310)) ## 3.17.2 diff --git a/src/compiler/compile/render_ssr/handlers/Title.ts b/src/compiler/compile/render_ssr/handlers/Title.ts index a3f271ab1b..f1f458ed5b 100644 --- a/src/compiler/compile/render_ssr/handlers/Title.ts +++ b/src/compiler/compile/render_ssr/handlers/Title.ts @@ -5,11 +5,7 @@ import { x } from 'code-red'; export default function(node: Title, renderer: Renderer, options: RenderOptions) { renderer.push(); - renderer.add_string('<title'); - if (options.hydratable && options.head_id) { - renderer.add_string(` data-svelte="${options.head_id}"`); - } - renderer.add_string('>'); + renderer.add_string(`<title>`); renderer.render(node.children, options); diff --git a/test/hydration/samples/head-meta-hydrate-duplicate/_before_head.html b/test/hydration/samples/head-meta-hydrate-duplicate/_before_head.html index d2f218fb8d..107753cdd0 100644 --- a/test/hydration/samples/head-meta-hydrate-duplicate/_before_head.html +++ b/test/hydration/samples/head-meta-hydrate-duplicate/_before_head.html @@ -1,4 +1,4 @@ -<title data-svelte="svelte-1s8aodm">Some Title +Some Title \ No newline at end of file diff --git a/test/server-side-rendering/samples/head-meta-hydrate-duplicate/_expected-head.html b/test/server-side-rendering/samples/head-meta-hydrate-duplicate/_expected-head.html index d2f218fb8d..107753cdd0 100644 --- a/test/server-side-rendering/samples/head-meta-hydrate-duplicate/_expected-head.html +++ b/test/server-side-rendering/samples/head-meta-hydrate-duplicate/_expected-head.html @@ -1,4 +1,4 @@ -Some Title +Some Title \ No newline at end of file From fd9b23e5e469399ef30a34dec9c070bc8eaf42a9 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Thu, 23 Jan 2020 10:07:41 -0500 Subject: [PATCH 02/16] -> v3.17.3 --- CHANGELOG.md | 2 +- package-lock.json | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70a4abab9a..a90d456444 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Svelte changelog -## Unreleased +## 3.17.3 * Fix updating a `` inside an `{#if}` or other block ([#4292](https://github.com/sveltejs/svelte/issues/4292)) * Fix using RxJS observables in `derived` stores ([#4298](https://github.com/sveltejs/svelte/issues/4298)) diff --git a/package-lock.json b/package-lock.json index ca225baa1b..cfbc71cdd2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "svelte", - "version": "3.17.2", + "version": "3.17.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 0910dca8c0..2b0b09299b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svelte", - "version": "3.17.2", + "version": "3.17.3", "description": "Cybernetically enhanced web apps", "module": "index.mjs", "main": "index", From f01bb639be2c832a6813edcd931b1fb886d3b01a Mon Sep 17 00:00:00 2001 From: Conduitry Date: Thu, 23 Jan 2020 10:40:22 -0500 Subject: [PATCH 03/16] make autosubscribing to a nullish store a no-op (#4304) * make autosubscribing to a nullish store a no-op (#2181) * update changelog * add test --- CHANGELOG.md | 1 + src/runtime/internal/utils.ts | 5 ++++- .../samples/store-auto-subscribe-nullish/_config.js | 13 +++++++++++++ .../store-auto-subscribe-nullish/main.svelte | 5 +++++ 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 test/runtime/samples/store-auto-subscribe-nullish/_config.js create mode 100644 test/runtime/samples/store-auto-subscribe-nullish/main.svelte diff --git a/CHANGELOG.md b/CHANGELOG.md index a90d456444..7ff7d7603b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## 3.17.3 +* Make autosubscribing to a nullish store a no-op ([#2181](https://github.com/sveltejs/svelte/issues/2181)) * Fix updating a `` inside an `{#if}` or other block ([#4292](https://github.com/sveltejs/svelte/issues/4292)) * Fix using RxJS observables in `derived` stores ([#4298](https://github.com/sveltejs/svelte/issues/4298)) * Add dev mode check to disallow duplicate keys in a keyed `{#each}` ([#4301](https://github.com/sveltejs/svelte/issues/4301)) diff --git a/src/runtime/internal/utils.ts b/src/runtime/internal/utils.ts index c7722e1a07..4ba7e18c15 100644 --- a/src/runtime/internal/utils.ts +++ b/src/runtime/internal/utils.ts @@ -43,12 +43,15 @@ export function not_equal(a, b) { } export function validate_store(store, name) { - if (!store || typeof store.subscribe !== 'function') { + if (store != null && typeof store.subscribe !== 'function') { throw new Error(`'${name}' is not a store with a 'subscribe' method`); } } export function subscribe(store, ...callbacks) { + if (store == null) { + return noop; + } const unsub = store.subscribe(...callbacks); return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub; } diff --git a/test/runtime/samples/store-auto-subscribe-nullish/_config.js b/test/runtime/samples/store-auto-subscribe-nullish/_config.js new file mode 100644 index 0000000000..52e21cef05 --- /dev/null +++ b/test/runtime/samples/store-auto-subscribe-nullish/_config.js @@ -0,0 +1,13 @@ +import { writable } from '../../../../store'; + +export default { + html: ` +

undefined

+ `, + async test({ assert, component, target }) { + component.store = writable('foo'); + assert.htmlEqual(target.innerHTML, ` +

foo

+ `); + } +}; diff --git a/test/runtime/samples/store-auto-subscribe-nullish/main.svelte b/test/runtime/samples/store-auto-subscribe-nullish/main.svelte new file mode 100644 index 0000000000..9c1ed4a560 --- /dev/null +++ b/test/runtime/samples/store-auto-subscribe-nullish/main.svelte @@ -0,0 +1,5 @@ + + +

{$store}

From 9cdf0da160d906948a4b4bbaebaf856751906177 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Thu, 23 Jan 2020 10:44:35 -0500 Subject: [PATCH 04/16] fix changelog --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ff7d7603b..44253ce59c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,11 @@ # Svelte changelog -## 3.17.3 +## Unreleased * Make autosubscribing to a nullish store a no-op ([#2181](https://github.com/sveltejs/svelte/issues/2181)) + +## 3.17.3 + * Fix updating a `` inside an `{#if}` or other block ([#4292](https://github.com/sveltejs/svelte/issues/4292)) * Fix using RxJS observables in `derived` stores ([#4298](https://github.com/sveltejs/svelte/issues/4298)) * Add dev mode check to disallow duplicate keys in a keyed `{#each}` ([#4301](https://github.com/sveltejs/svelte/issues/4301)) From bf006a43e5fd2339adb6cfca1a322fdedcbf48da Mon Sep 17 00:00:00 2001 From: Dave Lunny <4298089+himynameisdave@users.noreply.github.com> Date: Thu, 23 Jan 2020 17:51:29 -0800 Subject: [PATCH 05/16] [Internals] Improve unit tests (#4262) --- .github/workflows/ci.yml | 6 ++++++ src/compiler/compile/utils/__test__.ts | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2488902b24..14824ecdfa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,3 +23,9 @@ jobs: - uses: actions/checkout@v1 - uses: actions/setup-node@v1 - run: 'npm i && npm run lint' + Unit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-node@v1 + - run: 'npm i && npm run test:unit' diff --git a/src/compiler/compile/utils/__test__.ts b/src/compiler/compile/utils/__test__.ts index 60ad681b47..7777bc6afb 100644 --- a/src/compiler/compile/utils/__test__.ts +++ b/src/compiler/compile/utils/__test__.ts @@ -10,7 +10,7 @@ describe('get_name_from_filename', () => { assert.equal(get_name_from_filename('path/to/Widget/index.svelte'), 'Widget'); }); - it('handles unusual filenames', () => { - assert.equal(get_name_from_filename('path/to/[...parts].svelte'), 'Parts'); + it('handles Windows filenames', () => { + assert.equal(get_name_from_filename('path\\to\\Widget.svelte'), 'Widget'); }); }); From 8e245dc30ea971da953b1806ed980044546a03a9 Mon Sep 17 00:00:00 2001 From: David Kondrad Date: Sat, 25 Jan 2020 12:21:55 -0500 Subject: [PATCH 06/16] Internals: Scheduler: Fix infinite loop in flush (#4316) --- src/runtime/internal/scheduler.ts | 7 ++++--- .../lifecycle-onmount-infinite-loop/Child.svelte | 1 + .../lifecycle-onmount-infinite-loop/_config.js | 6 ++++++ .../lifecycle-onmount-infinite-loop/main.svelte | 16 ++++++++++++++++ 4 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 test/runtime/samples/lifecycle-onmount-infinite-loop/Child.svelte create mode 100644 test/runtime/samples/lifecycle-onmount-infinite-loop/_config.js create mode 100644 test/runtime/samples/lifecycle-onmount-infinite-loop/main.svelte diff --git a/src/runtime/internal/scheduler.ts b/src/runtime/internal/scheduler.ts index 04c1264ab1..1ce255b217 100644 --- a/src/runtime/internal/scheduler.ts +++ b/src/runtime/internal/scheduler.ts @@ -31,8 +31,8 @@ export function add_flush_callback(fn) { flush_callbacks.push(fn); } +const seen_callbacks = new Set(); export function flush() { - const seen_callbacks = new Set(); do { // first, call beforeUpdate functions @@ -52,10 +52,10 @@ export function flush() { const callback = render_callbacks[i]; if (!seen_callbacks.has(callback)) { - callback(); - // ...so guard against infinite loops seen_callbacks.add(callback); + + callback(); } } @@ -67,6 +67,7 @@ export function flush() { } update_scheduled = false; + seen_callbacks.clear(); } function update($$) { diff --git a/test/runtime/samples/lifecycle-onmount-infinite-loop/Child.svelte b/test/runtime/samples/lifecycle-onmount-infinite-loop/Child.svelte new file mode 100644 index 0000000000..ef16875b64 --- /dev/null +++ b/test/runtime/samples/lifecycle-onmount-infinite-loop/Child.svelte @@ -0,0 +1 @@ +Child diff --git a/test/runtime/samples/lifecycle-onmount-infinite-loop/_config.js b/test/runtime/samples/lifecycle-onmount-infinite-loop/_config.js new file mode 100644 index 0000000000..a76a2686ac --- /dev/null +++ b/test/runtime/samples/lifecycle-onmount-infinite-loop/_config.js @@ -0,0 +1,6 @@ +export default { + test({ assert, component }) { + const { count } = component; + assert.deepEqual(count, 1); + } +}; diff --git a/test/runtime/samples/lifecycle-onmount-infinite-loop/main.svelte b/test/runtime/samples/lifecycle-onmount-infinite-loop/main.svelte new file mode 100644 index 0000000000..1fa4263e39 --- /dev/null +++ b/test/runtime/samples/lifecycle-onmount-infinite-loop/main.svelte @@ -0,0 +1,16 @@ + + +
From 5d4408ba23655c54e8b921e27461273dc5e63610 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Sat, 25 Jan 2020 12:23:50 -0500 Subject: [PATCH 07/16] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44253ce59c..b5784f4148 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +* Fix infinite loop when instantiating another component during `onMount` ([#3218](https://github.com/sveltejs/svelte/issues/3218)) * Make autosubscribing to a nullish store a no-op ([#2181](https://github.com/sveltejs/svelte/issues/2181)) ## 3.17.3 From efe8ab9ca569b8cc706cb4c231b39c160ba479e3 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Sat, 25 Jan 2020 12:26:19 -0500 Subject: [PATCH 08/16] -> v3.18.0 --- CHANGELOG.md | 2 +- package-lock.json | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5784f4148..ed6feef9d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Svelte changelog -## Unreleased +## 3.18.0 * Fix infinite loop when instantiating another component during `onMount` ([#3218](https://github.com/sveltejs/svelte/issues/3218)) * Make autosubscribing to a nullish store a no-op ([#2181](https://github.com/sveltejs/svelte/issues/2181)) diff --git a/package-lock.json b/package-lock.json index cfbc71cdd2..6300fd40ac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "svelte", - "version": "3.17.3", + "version": "3.18.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 2b0b09299b..791327d3f0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svelte", - "version": "3.17.3", + "version": "3.18.0", "description": "Cybernetically enhanced web apps", "module": "index.mjs", "main": "index", From 3eb298fd28ff68f782f632a9029b430745cb0c2b Mon Sep 17 00:00:00 2001 From: Conduitry Date: Mon, 27 Jan 2020 14:02:30 -0500 Subject: [PATCH 09/16] fix code generation with adjacent inline and block comments (#4327) --- CHANGELOG.md | 4 ++++ package-lock.json | 6 +++--- package.json | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed6feef9d4..217651e20b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Svelte changelog +## Unreleased + +* Fix code generation error with adjacent inline and block comments ([#4312](https://github.com/sveltejs/svelte/issues/4312)) + ## 3.18.0 * Fix infinite loop when instantiating another component during `onMount` ([#3218](https://github.com/sveltejs/svelte/issues/3218)) diff --git a/package-lock.json b/package-lock.json index 6300fd40ac..5ffb1ba0da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -597,9 +597,9 @@ "dev": true }, "code-red": { - "version": "0.0.31", - "resolved": "https://registry.npmjs.org/code-red/-/code-red-0.0.31.tgz", - "integrity": "sha512-7Gf3vm8pDbs+H/hKsaqOZe0xKlE9Neah12GCfs7qun3fBUaOXwexAMjn0Eo9cvJJvhRMaL0jgPiY9ZGLTWoe8A==", + "version": "0.0.32", + "resolved": "https://registry.npmjs.org/code-red/-/code-red-0.0.32.tgz", + "integrity": "sha512-mE+EZc2vJ4HxiejW5S2CvcVDKtopFEmrqAd9DTBDLCNjLgxekPP8wLi/ZiwDTwZwwW3dzeetaubLaMlIvkhVNw==", "dev": true, "requires": { "acorn": "^7.1.0", diff --git a/package.json b/package.json index 791327d3f0..3b43d6fa46 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ "acorn": "^7.1.0", "agadoo": "^1.1.0", "c8": "^5.0.1", - "code-red": "0.0.31", + "code-red": "0.0.32", "codecov": "^3.5.0", "css-tree": "1.0.0-alpha22", "eslint": "^6.3.0", From 43f19d93a9fe33ec71856d7b080aca1425460a3e Mon Sep 17 00:00:00 2001 From: Wolfr Date: Mon, 27 Jan 2020 20:28:06 +0100 Subject: [PATCH 10/16] site: Improve open graph images for website (#4328) --- site/src/template.html | 1 + 1 file changed, 1 insertion(+) diff --git a/site/src/template.html b/site/src/template.html index dc930a7f72..344684d766 100644 --- a/site/src/template.html +++ b/site/src/template.html @@ -15,6 +15,7 @@ +