@@ -660,6 +660,13 @@ function serialize_inline_component(node, component_name, context) {
660
660
*/
661
661
let slot_scope_applies_to_itself = false ;
662
662
663
+ /**
664
+ * Components may have a children prop and also have child nodes. In this case, we assume
665
+ * that the child component isn't using render tags yet and pass the slot as $$slots.default.
666
+ * We're not doing it for spread attributes, as this would result in too many false positives.
667
+ */
668
+ let has_children_prop = false ;
669
+
663
670
/**
664
671
* @param {import('estree').Property } prop
665
672
*/
@@ -709,6 +716,10 @@ function serialize_inline_component(node, component_name, context) {
709
716
slot_scope_applies_to_itself = true ;
710
717
}
711
718
719
+ if ( attribute . name === 'children' ) {
720
+ has_children_prop = true ;
721
+ }
722
+
712
723
const [ , value ] = serialize_attribute_value ( attribute . value , context ) ;
713
724
714
725
if ( attribute . metadata . dynamic ) {
@@ -825,10 +836,13 @@ function serialize_inline_component(node, component_name, context) {
825
836
b . block ( [ ...( slot_name === 'default' && ! slot_scope_applies_to_itself ? lets : [ ] ) , ...body ] )
826
837
) ;
827
838
828
- if ( slot_name === 'default' ) {
839
+ if ( slot_name === 'default' && ! has_children_prop ) {
829
840
push_prop (
830
841
b . init ( 'children' , context . state . options . dev ? b . call ( '$.wrap_snippet' , slot_fn ) : slot_fn )
831
842
) ;
843
+ // We additionally add the default slot as a boolean, so that the slot render function on the other
844
+ // side knows it should get the content to render from $$props.children
845
+ serialized_slots . push ( b . init ( slot_name , b . true ) ) ;
832
846
} else {
833
847
serialized_slots . push ( b . init ( slot_name , slot_fn ) ) ;
834
848
}
@@ -3057,7 +3071,7 @@ export const template_visitors = {
3057
3071
) ;
3058
3072
3059
3073
const expression = is_default
3060
- ? b . member ( b . id ( '$$props' ) , b . id ( 'children ' ) )
3074
+ ? b . call ( '$.default_slot' , b . id ( '$$props ' ) )
3061
3075
: b . member ( b . member ( b . id ( '$$props' ) , b . id ( '$$slots' ) ) , name , true , true ) ;
3062
3076
3063
3077
const slot = b . call ( '$.slot' , context . state . node , expression , props_expression , fallback ) ;
0 commit comments