@@ -251,7 +251,11 @@ function apply_combinator(relative_selector, rest_selectors, rule, node, directi
251
251
let sibling_matched = false ;
252
252
253
253
for ( const possible_sibling of siblings . keys ( ) ) {
254
- if ( possible_sibling . type === 'RenderTag' || possible_sibling . type === 'SlotElement' ) {
254
+ if (
255
+ possible_sibling . type === 'RenderTag' ||
256
+ possible_sibling . type === 'SlotElement' ||
257
+ possible_sibling . type === 'Component'
258
+ ) {
255
259
// `{@render foo()}<p>foo</p>` with `:global(.x) + p` is a match
256
260
if ( rest_selectors . length === 1 && rest_selectors [ 0 ] . metadata . is_global ) {
257
261
sibling_matched = true ;
@@ -814,10 +818,10 @@ function get_element_parent(node) {
814
818
* @param {Direction } direction
815
819
* @param {boolean } adjacent_only
816
820
* @param {Set<Compiler.AST.SnippetBlock> } seen
817
- * @returns {Map<Compiler.AST.RegularElement | Compiler.AST.SvelteElement | Compiler.AST.SlotElement | Compiler.AST.RenderTag, NodeExistsValue> }
821
+ * @returns {Map<Compiler.AST.RegularElement | Compiler.AST.SvelteElement | Compiler.AST.SlotElement | Compiler.AST.RenderTag | Compiler.AST.Component , NodeExistsValue> }
818
822
*/
819
823
function get_possible_element_siblings ( node , direction , adjacent_only , seen = new Set ( ) ) {
820
- /** @type {Map<Compiler.AST.RegularElement | Compiler.AST.SvelteElement | Compiler.AST.SlotElement | Compiler.AST.RenderTag, NodeExistsValue> } */
824
+ /** @type {Map<Compiler.AST.RegularElement | Compiler.AST.SvelteElement | Compiler.AST.SlotElement | Compiler.AST.RenderTag | Compiler.AST.Component , NodeExistsValue> } */
821
825
const result = new Map ( ) ;
822
826
const path = node . metadata . path ;
823
827
@@ -847,14 +851,18 @@ function get_possible_element_siblings(node, direction, adjacent_only, seen = ne
847
851
}
848
852
// Special case: slots, render tags and svelte:element tags could resolve to no siblings,
849
853
// so we want to continue until we find a definite sibling even with the adjacent-only combinator
850
- } else if ( is_block ( node ) ) {
851
- if ( node . type === 'SlotElement' ) {
854
+ } else if ( is_block ( node ) || node . type === 'Component' ) {
855
+ if ( node . type === 'SlotElement' || node . type === 'Component' ) {
852
856
result . set ( node , NODE_PROBABLY_EXISTS ) ;
853
857
}
854
858
855
859
const possible_last_child = get_possible_nested_siblings ( node , direction , adjacent_only ) ;
856
860
add_to_map ( possible_last_child , result ) ;
857
- if ( adjacent_only && has_definite_elements ( possible_last_child ) ) {
861
+ if (
862
+ adjacent_only &&
863
+ node . type !== 'Component' &&
864
+ has_definite_elements ( possible_last_child )
865
+ ) {
858
866
return result ;
859
867
}
860
868
} else if ( node . type === 'SvelteElement' ) {
@@ -907,7 +915,7 @@ function get_possible_element_siblings(node, direction, adjacent_only, seen = ne
907
915
}
908
916
909
917
/**
910
- * @param {Compiler.AST.EachBlock | Compiler.AST.IfBlock | Compiler.AST.AwaitBlock | Compiler.AST.KeyBlock | Compiler.AST.SlotElement | Compiler.AST.SnippetBlock } node
918
+ * @param {Compiler.AST.EachBlock | Compiler.AST.IfBlock | Compiler.AST.AwaitBlock | Compiler.AST.KeyBlock | Compiler.AST.SlotElement | Compiler.AST.SnippetBlock | Compiler.AST.Component } node
911
919
* @param {Direction } direction
912
920
* @param {boolean } adjacent_only
913
921
* @param {Set<Compiler.AST.SnippetBlock> } seen
@@ -942,6 +950,10 @@ function get_possible_nested_siblings(node, direction, adjacent_only, seen = new
942
950
seen . add ( node ) ;
943
951
fragments . push ( node . body ) ;
944
952
break ;
953
+
954
+ case 'Component' :
955
+ fragments . push ( node . fragment , ...[ ...node . metadata . snippets ] . map ( ( s ) => s . body ) ) ;
956
+ break ;
945
957
}
946
958
947
959
/** @type {Map<Compiler.AST.RegularElement | Compiler.AST.SvelteElement, NodeExistsValue> } NodeMap */
0 commit comments