From 275b2cb251e6cc0902920f6c7c31602cccffabc7 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Wed, 16 Oct 2019 12:05:32 -0400 Subject: [PATCH 1/3] add test for breaking from a reactive block --- .../samples/reactive-block-break/_config.js | 3 +++ .../samples/reactive-block-break/main.svelte | 14 ++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 test/runtime/samples/reactive-block-break/_config.js create mode 100644 test/runtime/samples/reactive-block-break/main.svelte diff --git a/test/runtime/samples/reactive-block-break/_config.js b/test/runtime/samples/reactive-block-break/_config.js new file mode 100644 index 000000000000..f2d3e6a8f51b --- /dev/null +++ b/test/runtime/samples/reactive-block-break/_config.js @@ -0,0 +1,3 @@ +export default { + html: `

1 2

` +}; \ No newline at end of file diff --git a/test/runtime/samples/reactive-block-break/main.svelte b/test/runtime/samples/reactive-block-break/main.svelte new file mode 100644 index 000000000000..5b0aa005c035 --- /dev/null +++ b/test/runtime/samples/reactive-block-break/main.svelte @@ -0,0 +1,14 @@ + + +

{foo} {bar}

\ No newline at end of file From 2d1d855d4994c6a59a30669c0eecb61892575745 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Thu, 17 Oct 2019 09:33:09 -0400 Subject: [PATCH 2/3] preserve `$:` label in reactive blocks in SSR mode (#2828) --- src/compiler/compile/render_ssr/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/compiler/compile/render_ssr/index.ts b/src/compiler/compile/render_ssr/index.ts index d193508a89a6..00157cc2561f 100644 --- a/src/compiler/compile/render_ssr/index.ts +++ b/src/compiler/compile/render_ssr/index.ts @@ -98,6 +98,8 @@ export default function ssr( : b` let ${left} = ${right}`; } + } else { // TODO do not add label if it's not referenced + statement = b`$: { ${statement} }`; } return statement; From 11fff71a89b38097fb34314a728638b959e4b240 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Thu, 17 Oct 2019 09:46:46 -0400 Subject: [PATCH 3/3] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fa087e03a06..e19af3e53fa1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Fix `{#each}` context not shadowing outer scope when using `bind:` ([#1565](https://github.com/sveltejs/svelte/issues/1565)) * Fix edge cases in matching selectors against elements ([#1710](https://github.com/sveltejs/svelte/issues/1710)) +* Allow exiting a reactive block early with `break $` ([#2828](https://github.com/sveltejs/svelte/issues/2828)) * Check attributes have changed before setting them to avoid image flicker ([#3579](https://github.com/sveltejs/svelte/pull/3579)) * Fix generating malformed code for `{@debug}` tags with no dependencies ([#3588](https://github.com/sveltejs/svelte/issue/3588)) * Use safer `HTMLElement` check before extending class ([#3608](https://github.com/sveltejs/svelte/issue/3608))