Skip to content

Commit dda9a53

Browse files
authored
preserve $: label in reactive blocks in SSR mode (#2828) (#3469)
1 parent ddbbccc commit dda9a53

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
* Fix `{#each}` context not shadowing outer scope when using `bind:` ([#1565](https://github.com/sveltejs/svelte/issues/1565))
66
* Fix edge cases in matching selectors against elements ([#1710](https://github.com/sveltejs/svelte/issues/1710))
7+
* Allow exiting a reactive block early with `break $` ([#2828](https://github.com/sveltejs/svelte/issues/2828))
78
* Check attributes have changed before setting them to avoid image flicker ([#3579](https://github.com/sveltejs/svelte/pull/3579))
89
* Fix generating malformed code for `{@debug}` tags with no dependencies ([#3588](https://github.com/sveltejs/svelte/issue/3588))
910
* Use safer `HTMLElement` check before extending class ([#3608](https://github.com/sveltejs/svelte/issue/3608))

src/compiler/compile/render_ssr/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ export default function ssr(
9898
: b`
9999
let ${left} = ${right}`;
100100
}
101+
} else { // TODO do not add label if it's not referenced
102+
statement = b`$: { ${statement} }`;
101103
}
102104

103105
return statement;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default {
2+
html: `<h1>1 2</h1>`
3+
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<script>
2+
let foo = 0;
3+
let bar;
4+
$: {
5+
bar = foo + 1;
6+
if (foo) {
7+
break $;
8+
}
9+
bar = foo + 2;
10+
}
11+
foo = 1;
12+
</script>
13+
14+
<h1>{foo} {bar}</h1>

0 commit comments

Comments
 (0)