fix: migrate reactive statements with inner blocks

pull/13675/head
Dominic Gannaway 2 years ago
parent 0598f2bbe1
commit 82e84a8010

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

@ -570,7 +570,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