Skip to content

Commit f398929

Browse files
authored
fix: correct migration of uninitialised state (#13673)
* fix: correct migration of uninitialised state * better fix
1 parent 0598f2b commit f398929

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

.changeset/neat-rabbits-divide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: correct migration of uninitialised state

packages/svelte/src/compiler/migrate/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,12 @@ const instance_script = {
564564
labeled_statement = /** @type {LabeledStatement} */ (labeled);
565565
}
566566

567-
return !update && (declaration || (labeled && assignment) || (!labeled && !assignment));
567+
return (
568+
!update &&
569+
((declaration && binding.initial) ||
570+
(labeled && assignment) ||
571+
(!labeled && !assignment))
572+
);
568573
})
569574
);
570575

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<script lang="ts">
2+
let bounds: DOMRect | undefined;
3+
$: position = calculatePosition(bounds);
4+
5+
const openDropdown = () => {
6+
bounds = getInputPosition();
7+
};
8+
9+
const getInputPosition = () => {};
10+
const calculatePosition = (boundary?: DOMRect) => ({});
11+
</script>
12+
13+
<div style:top={position.top}></div>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<script lang="ts">
2+
let bounds: DOMRect | undefined = $state();
3+
4+
const openDropdown = () => {
5+
bounds = getInputPosition();
6+
};
7+
8+
const getInputPosition = () => {};
9+
const calculatePosition = (boundary?: DOMRect) => ({});
10+
let position = $derived(calculatePosition(bounds));
11+
</script>
12+
13+
<div style:top={position.top}></div>

0 commit comments

Comments
 (0)