@@ -944,15 +944,16 @@ function get_possible_element_siblings(node, adjacent_only) {
944944 let prev = node ;
945945 while ( ( prev = find_previous_sibling ( prev ) ) ) {
946946 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 ) {
952952 result . set ( prev , NODE_DEFINITELY_EXISTS ) ;
953- }
954- if ( adjacent_only ) {
955- break ;
953+
954+ if ( adjacent_only ) {
955+ return result ;
956+ }
956957 }
957958 } else if ( is_block ( prev ) ) {
958959 const possible_last_child = get_possible_last_child ( prev , adjacent_only ) ;
@@ -971,27 +972,25 @@ function get_possible_element_siblings(node, adjacent_only) {
971972 }
972973 }
973974
974- if ( ! prev || ! adjacent_only ) {
975- /** @type {Compiler.SvelteNode | null } */
976- let parent = node ;
975+ /** @type {Compiler.SvelteNode | null } */
976+ let parent = node ;
977977
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 ) ;
985985
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+ }
991991
992- if ( adjacent_only && has_definite_elements ( possible_siblings ) ) {
993- break ;
994- }
992+ if ( adjacent_only && has_definite_elements ( possible_siblings ) ) {
993+ break ;
995994 }
996995 }
997996
0 commit comments