@@ -322,6 +322,64 @@ describe('scrim', () => {
322322 } )
323323 } )
324324
325+ describe ( 'renderless' , ( ) => {
326+ it ( 'should render no wrapper and carry the element contract in slot attrs' , async ( ) => {
327+ let captured : any
328+ const ticket = createMockTicket ( { zIndex : 2500 } )
329+ mockSelectedItems . value = new Set ( [ ticket ] )
330+
331+ const wrapper = mount ( Scrim , {
332+ props : { teleport : false , renderless : true } ,
333+ slots : {
334+ default : ( props : any ) => {
335+ captured = props
336+ return h ( 'aside' , { class : 'custom-scrim' , ...props . attrs } )
337+ } ,
338+ } ,
339+ } )
340+
341+ await nextTick ( )
342+ const custom = wrapper . find ( '.custom-scrim' )
343+ expect ( custom . exists ( ) ) . toBe ( true )
344+ expect ( wrapper . findAll ( '.custom-scrim' ) ) . toHaveLength ( 1 )
345+ expect ( wrapper . findAll ( 'div' ) ) . toHaveLength ( 0 )
346+ expect ( captured . attrs . style . zIndex ) . toBe ( 2499 )
347+ expect ( ( custom . element as HTMLElement ) . style . zIndex ) . toBe ( '2499' )
348+
349+ await custom . trigger ( 'click' )
350+ expect ( ticket . dismiss ) . toHaveBeenCalledTimes ( 1 )
351+ } )
352+
353+ it ( 'should dismiss from the consumer element when teleported' , async ( ) => {
354+ const target = document . createElement ( 'div' )
355+ target . id = 'renderless-target'
356+ document . body . append ( target )
357+
358+ const ticket = createMockTicket ( { zIndex : 3000 } )
359+ mockSelectedItems . value = new Set ( [ ticket ] )
360+
361+ mount ( Scrim , {
362+ props : { teleportTo : '#renderless-target' , renderless : true } ,
363+ attachTo : document . body ,
364+ slots : {
365+ default : ( props : any ) => h ( 'aside' , { class : 'custom-scrim' , ...props . attrs } ) ,
366+ } ,
367+ } )
368+
369+ await nextTick ( )
370+ const custom = target . querySelector ( '.custom-scrim' ) as HTMLElement
371+ expect ( custom ) . toBeTruthy ( )
372+ expect ( target . contains ( custom ) ) . toBe ( true )
373+ expect ( target . querySelector ( 'div' ) ) . toBeNull ( )
374+ expect ( custom . style . zIndex ) . toBe ( '2999' )
375+
376+ custom . dispatchEvent ( new MouseEvent ( 'click' , { bubbles : true } ) )
377+ expect ( ticket . dismiss ) . toHaveBeenCalledTimes ( 1 )
378+
379+ target . remove ( )
380+ } )
381+ } )
382+
325383 describe ( 'transition' , ( ) => {
326384 it ( 'should use fade transition by default' , async ( ) => {
327385 const ticket = createMockTicket ( )
0 commit comments