@@ -944,15 +944,16 @@ function get_possible_element_siblings(node, adjacent_only) {
944
944
let prev = node ;
945
945
while ( ( prev = find_previous_sibling ( prev ) ) ) {
946
946
if ( prev . type === 'RegularElement' ) {
947
- if (
948
- ! prev . attributes . find (
949
- ( attr ) => attr . type === 'Attribute' && attr . name . toLowerCase ( ) === 'slot'
950
- )
951
- ) {
947
+ const has_slot_attribute = prev . attributes . some (
948
+ ( attr ) => attr . type === 'Attribute' && attr . name . toLowerCase ( ) === 'slot'
949
+ ) ;
950
+
951
+ if ( ! has_slot_attribute ) {
952
952
result . set ( prev , NODE_DEFINITELY_EXISTS ) ;
953
- }
954
- if ( adjacent_only ) {
955
- break ;
953
+
954
+ if ( adjacent_only ) {
955
+ return result ;
956
+ }
956
957
}
957
958
} else if ( is_block ( prev ) ) {
958
959
const possible_last_child = get_possible_last_child ( prev , adjacent_only ) ;
@@ -971,27 +972,25 @@ function get_possible_element_siblings(node, adjacent_only) {
971
972
}
972
973
}
973
974
974
- if ( ! prev || ! adjacent_only ) {
975
- /** @type {Compiler.SvelteNode | null } */
976
- let parent = node ;
975
+ /** @type {Compiler.SvelteNode | null } */
976
+ let parent = node ;
977
977
978
- while (
979
- // @ts -expect-error TODO
980
- ( parent = parent ?. parent ) &&
981
- is_block ( parent )
982
- ) {
983
- const possible_siblings = get_possible_element_siblings ( parent , adjacent_only ) ;
984
- add_to_map ( possible_siblings , result ) ;
978
+ while (
979
+ // @ts -expect-error TODO
980
+ ( parent = parent ?. parent ) &&
981
+ is_block ( parent )
982
+ ) {
983
+ const possible_siblings = get_possible_element_siblings ( parent , adjacent_only ) ;
984
+ add_to_map ( possible_siblings , result ) ;
985
985
986
- // @ts -expect-error
987
- if ( parent . type === 'EachBlock' && ! parent . fallback ?. nodes . includes ( node ) ) {
988
- // `{#each ...}<a /><b />{/each}` — `<b>` can be previous sibling of `<a />`
989
- add_to_map ( get_possible_last_child ( parent , adjacent_only ) , result ) ;
990
- }
986
+ // @ts -expect-error
987
+ if ( parent . type === 'EachBlock' && ! parent . fallback ?. nodes . includes ( node ) ) {
988
+ // `{#each ...}<a /><b />{/each}` — `<b>` can be previous sibling of `<a />`
989
+ add_to_map ( get_possible_last_child ( parent , adjacent_only ) , result ) ;
990
+ }
991
991
992
- if ( adjacent_only && has_definite_elements ( possible_siblings ) ) {
993
- break ;
994
- }
992
+ if ( adjacent_only && has_definite_elements ( possible_siblings ) ) {
993
+ break ;
995
994
}
996
995
}
997
996
0 commit comments