fix: migrate reactive statements with inner blocks (#13675)

pull/13678/head
Dominic Gannaway 3 months ago committed by GitHub
parent f398929fdd
commit c9d85c2d52
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: migrate reactive statements with inner blocks

@ -575,7 +575,8 @@ const instance_script = {
const labeled_has_single_assignment =
labeled_statement?.body.type === 'BlockStatement' &&
labeled_statement.body.body.length === 1;
labeled_statement.body.body.length === 1 &&
labeled_statement.body.body[0].type === 'ExpressionStatement';
const is_expression_assignment =
labeled_statement?.body.type === 'ExpressionStatement' &&

@ -0,0 +1,17 @@
<script lang="ts">
let menuElement: HTMLUListElement | undefined = undefined;
let left: number;
let top: number;
$: {
if (menuElement) {
const rect = menuElement.getBoundingClientRect();
const menuHeight = 0;
left = window.innerWidth - rect.width
top = window.innerHeight - menuHeight;
}
}
</script>
<ul bind:this={menuElement}></ul>

@ -0,0 +1,19 @@
<script lang="ts">
import { run } from 'svelte/legacy';
let menuElement: HTMLUListElement | undefined = $state(undefined);
let left: number = $state();
let top: number = $state();
run(() => {
if (menuElement) {
const rect = menuElement.getBoundingClientRect();
const menuHeight = 0;
left = window.innerWidth - rect.width
top = window.innerHeight - menuHeight;
}
});
</script>
<ul bind:this={menuElement}></ul>
Loading…
Cancel
Save