@@ -115,6 +115,50 @@ describe('renderSlot', () => {
115115 expect ( slot . key ) . toBe ( 'user' )
116116 } )
117117
118+ it ( 'should handle nullish props' , ( ) => {
119+ for ( const props of [ null , undefined ] ) {
120+ let receivedProps : any
121+ const vnode = renderSlot (
122+ {
123+ default : props => {
124+ receivedProps = props
125+ return [ h ( 'div' ) ]
126+ } ,
127+ } ,
128+ 'default' ,
129+ props ,
130+ )
131+ expect ( receivedProps ) . toEqual ( { } )
132+ expect ( vnode . key ) . toBe ( '_default' )
133+ }
134+ } )
135+
136+ it ( 'should handle nullish props with a compiler-injected slot key' , ( ) => {
137+ for ( const props of [ null , undefined ] ) {
138+ const vnode = renderSlot (
139+ { default : ( ) => [ h ( 'div' ) ] } ,
140+ 'default' ,
141+ props ,
142+ undefined ,
143+ undefined ,
144+ 'branch' ,
145+ )
146+ expect ( vnode . key ) . toBe ( 'branch' )
147+ }
148+ } )
149+
150+ it ( 'should handle nullish props in custom element mode' , ( ) => {
151+ setCurrentRenderingInstance ( { type : { } , ce : { } } as any )
152+
153+ for ( const props of [ null , undefined ] ) {
154+ const vnode = renderSlot ( { } , 'foo' , props , undefined , undefined , 'branch' )
155+ const slot = ( vnode . children as any [ ] ) [ 0 ]
156+ expect ( slot . type ) . toBe ( 'slot' )
157+ expect ( slot . key ) . toBe ( 'branch' )
158+ expect ( slot . props . name ) . toBe ( 'foo' )
159+ }
160+ } )
161+
118162 it ( 'should render slot fallback' , ( ) => {
119163 const vnode = renderSlot ( { } , 'default' , { key : 'foo' } , ( ) => [ 'fallback' ] )
120164 expect ( vnode . children ) . toEqual ( [ 'fallback' ] )
0 commit comments