File tree Expand file tree Collapse file tree 4 files changed +43
-1
lines changed
tests/migrate/samples/reactive-statements-inner-block Expand file tree Collapse file tree 4 files changed +43
-1
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' svelte ' : patch
3
+ ---
4
+
5
+ fix: migrate reactive statements with inner blocks
Original file line number Diff line number Diff line change @@ -575,7 +575,8 @@ const instance_script = {
575
575
576
576
const labeled_has_single_assignment =
577
577
labeled_statement ?. body . type === 'BlockStatement' &&
578
- labeled_statement . body . body . length === 1 ;
578
+ labeled_statement . body . body . length === 1 &&
579
+ labeled_statement . body . body [ 0 ] . type === 'ExpressionStatement' ;
579
580
580
581
const is_expression_assignment =
581
582
labeled_statement ?. body . type === 'ExpressionStatement' &&
Original file line number Diff line number Diff line change
1
+ <script lang =" ts" >
2
+ let menuElement: HTMLUListElement | undefined = undefined ;
3
+ let left: number ;
4
+ let top: number ;
5
+
6
+ $ : {
7
+ if (menuElement ) {
8
+ const rect = menuElement .getBoundingClientRect ();
9
+ const menuHeight = 0 ;
10
+
11
+ left = window .innerWidth - rect .width
12
+ top = window .innerHeight - menuHeight ;
13
+ }
14
+ }
15
+ </script >
16
+
17
+ <ul bind:this ={menuElement }></ul >
Original file line number Diff line number Diff line change
1
+ <script lang =" ts" >
2
+ import { run } from ' svelte/legacy' ;
3
+
4
+ let menuElement: HTMLUListElement | undefined = $state (undefined );
5
+ let left: number = $state ();
6
+ let top: number = $state ();
7
+
8
+ run (() => {
9
+ if (menuElement ) {
10
+ const rect = menuElement .getBoundingClientRect ();
11
+ const menuHeight = 0 ;
12
+
13
+ left = window .innerWidth - rect .width
14
+ top = window .innerHeight - menuHeight ;
15
+ }
16
+ });
17
+ </script >
18
+
19
+ <ul bind:this ={menuElement }></ul >
You can’t perform that action at this time.
0 commit comments