@@ -461,6 +461,54 @@ test('before and after variants are a bit special, and forced to the end (2)', (
461461 } )
462462} )
463463
464+ test ( 'returning non-strings and non-selectors in addVariant' , ( ) => {
465+ /** @type {import('../types/config').Config } */
466+ let config = {
467+ content : [
468+ {
469+ raw : html `
470+ <div class= "peer-aria-expanded:text-center" > </ div>
471+ <div class= "peer-aria-expanded-2:text-center" > </ div>
472+ ` ,
473+ } ,
474+ ] ,
475+ plugins : [
476+ function ( { addVariant, e } ) {
477+ addVariant ( 'peer-aria-expanded' , ( { modifySelectors, separator } ) =>
478+ // Returning anything other string | string[] | undefined here is not supported
479+ // But we're trying to be lenient here and just throw it out
480+ modifySelectors (
481+ ( { className } ) =>
482+ `.peer[aria-expanded="true"] ~ .${ e ( `peer-aria-expanded${ separator } ${ className } ` ) } `
483+ )
484+ )
485+
486+ addVariant ( 'peer-aria-expanded-2' , ( { modifySelectors, separator } ) => {
487+ let nodes = modifySelectors (
488+ ( { className } ) =>
489+ `.peer[aria-expanded="false"] ~ .${ e ( `peer-aria-expanded${ separator } ${ className } ` ) } `
490+ )
491+
492+ return [
493+ // Returning anything other than strings here is not supported
494+ // But we're trying to be lenient here and just throw it out
495+ nodes ,
496+ '.peer[aria-expanded="false"] ~ &' ,
497+ ]
498+ } )
499+ } ,
500+ ] ,
501+ }
502+
503+ return run ( '@tailwind components;@tailwind utilities' , config ) . then ( ( result ) => {
504+ return expect ( result . css ) . toMatchFormattedCss ( css `
505+ .peer [aria-expanded = 'true' ] ~ .peer-aria-expanded\:text-center {
506+ text-align : center;
507+ }
508+ ` )
509+ } )
510+ } )
511+
464512it ( 'should not generate variants of user css if it is not inside a layer' , ( ) => {
465513 let config = {
466514 content : [ { raw : html `<div class= "hover:foo" > </ div> ` } ] ,
0 commit comments