Skip to content

Preserve $: label in SSR mode #3726

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 2 additions & 0 deletions src/compiler/compile/render_ssr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions test/runtime/samples/reactive-block-break/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
html: `<h1>1 2</h1>`
};
14 changes: 14 additions & 0 deletions test/runtime/samples/reactive-block-break/main.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<script>
let foo = 0;
let bar;
$: {
bar = foo + 1;
if (foo) {
break $;
}
bar = foo + 2;
}
foo = 1;
</script>

<h1>{foo} {bar}</h1>