@@ -906,15 +906,16 @@ function get_possible_element_siblings(node, adjacent_only) {
906906 let prev = node ;
907907 while ( ( prev = find_previous_sibling ( prev ) ) ) {
908908 if ( prev . type === 'RegularElement' ) {
909- if (
910- ! prev . attributes . find (
911- ( attr ) => attr . type === 'Attribute' && attr . name . toLowerCase ( ) === 'slot'
912- )
913- ) {
909+ const has_slot_attribute = prev . attributes . some (
910+ ( attr ) => attr . type === 'Attribute' && attr . name . toLowerCase ( ) === 'slot'
911+ ) ;
912+
913+ if ( ! has_slot_attribute ) {
914914 result . set ( prev , NODE_DEFINITELY_EXISTS ) ;
915- }
916- if ( adjacent_only ) {
917- break ;
915+
916+ if ( adjacent_only ) {
917+ return result ;
918+ }
918919 }
919920 } else if ( is_block ( prev ) ) {
920921 const possible_last_child = get_possible_last_child ( prev , adjacent_only ) ;
@@ -933,27 +934,25 @@ function get_possible_element_siblings(node, adjacent_only) {
933934 }
934935 }
935936
936- if ( ! prev || ! adjacent_only ) {
937- /** @type {Compiler.SvelteNode | null } */
938- let parent = node ;
937+ /** @type {Compiler.SvelteNode | null } */
938+ let parent = node ;
939939
940- while (
941- // @ts -expect-error TODO
942- ( parent = parent ?. parent ) &&
943- is_block ( parent )
944- ) {
945- const possible_siblings = get_possible_element_siblings ( parent , adjacent_only ) ;
946- add_to_map ( possible_siblings , result ) ;
940+ while (
941+ // @ts -expect-error TODO
942+ ( parent = parent ?. parent ) &&
943+ is_block ( parent )
944+ ) {
945+ const possible_siblings = get_possible_element_siblings ( parent , adjacent_only ) ;
946+ add_to_map ( possible_siblings , result ) ;
947947
948- // @ts -expect-error
949- if ( parent . type === 'EachBlock' && ! parent . fallback ?. nodes . includes ( node ) ) {
950- // `{#each ...}<a /><b />{/each}` — `<b>` can be previous sibling of `<a />`
951- add_to_map ( get_possible_last_child ( parent , adjacent_only ) , result ) ;
952- }
948+ // @ts -expect-error
949+ if ( parent . type === 'EachBlock' && ! parent . fallback ?. nodes . includes ( node ) ) {
950+ // `{#each ...}<a /><b />{/each}` — `<b>` can be previous sibling of `<a />`
951+ add_to_map ( get_possible_last_child ( parent , adjacent_only ) , result ) ;
952+ }
953953
954- if ( adjacent_only && has_definite_elements ( possible_siblings ) ) {
955- break ;
956- }
954+ if ( adjacent_only && has_definite_elements ( possible_siblings ) ) {
955+ break ;
957956 }
958957 }
959958
0 commit comments