@@ -955,12 +955,7 @@ function get_possible_element_siblings(node, adjacent_only) {
955
955
if ( adjacent_only ) {
956
956
break ;
957
957
}
958
- } else if (
959
- prev . type === 'EachBlock' ||
960
- prev . type === 'IfBlock' ||
961
- prev . type === 'AwaitBlock' ||
962
- prev . type === 'KeyBlock'
963
- ) {
958
+ } else if ( is_block ( prev ) ) {
964
959
const possible_last_child = get_possible_last_child ( prev , adjacent_only ) ;
965
960
add_to_map ( possible_last_child , result ) ;
966
961
if ( adjacent_only && has_definite_elements ( possible_last_child ) ) {
@@ -984,10 +979,7 @@ function get_possible_element_siblings(node, adjacent_only) {
984
979
while (
985
980
// @ts -expect-error TODO
986
981
( parent = parent ?. parent ) &&
987
- ( parent . type === 'EachBlock' ||
988
- parent . type === 'IfBlock' ||
989
- parent . type === 'AwaitBlock' ||
990
- parent . type === 'KeyBlock' )
982
+ is_block ( parent )
991
983
) {
992
984
const possible_siblings = get_possible_element_siblings ( parent , adjacent_only ) ;
993
985
add_to_map ( possible_siblings , result ) ;
@@ -1117,11 +1109,7 @@ function loop_child(children, adjacent_only) {
1117
1109
if ( adjacent_only ) {
1118
1110
break ;
1119
1111
}
1120
- } else if (
1121
- child . type === 'EachBlock' ||
1122
- child . type === 'IfBlock' ||
1123
- child . type === 'AwaitBlock'
1124
- ) {
1112
+ } else if ( is_block ( child ) ) {
1125
1113
const child_result = get_possible_last_child ( child , adjacent_only ) ;
1126
1114
add_to_map ( child_result , result ) ;
1127
1115
if ( adjacent_only && has_definite_elements ( child_result ) ) {
@@ -1132,3 +1120,16 @@ function loop_child(children, adjacent_only) {
1132
1120
1133
1121
return result ;
1134
1122
}
1123
+
1124
+ /**
1125
+ * @param {Compiler.SvelteNode } node
1126
+ * @returns {node is Compiler.AST.IfBlock | Compiler.AST.EachBlock | Compiler.AST.AwaitBlock | Compiler.AST.KeyBlock }
1127
+ */
1128
+ function is_block ( node ) {
1129
+ return (
1130
+ node . type === 'IfBlock' ||
1131
+ node . type === 'EachBlock' ||
1132
+ node . type === 'AwaitBlock' ||
1133
+ node . type === 'KeyBlock'
1134
+ ) ;
1135
+ }
0 commit comments