@@ -660,6 +660,72 @@ describe.each([['default'], ['with-variant'], ['important'], ['prefix']])('%s',
660
660
await expectCanonicalization ( input , candidate , expected )
661
661
} )
662
662
} )
663
+
664
+ describe ( 'arbitrary value to bare value' , ( ) => {
665
+ test . each ( [
666
+ [ 'aspect-[12/34]' , 'aspect-12/34' ] ,
667
+ [ 'aspect-[1.2/34]' , 'aspect-[1.2/34]' ] ,
668
+ [ 'col-start-[7]' , 'col-start-7' ] ,
669
+ [ 'flex-[2]' , 'flex-2' ] , // `flex` is implemented as static and functional utilities
670
+
671
+ [ 'grid-cols-[subgrid]' , 'grid-cols-subgrid' ] ,
672
+ [ 'grid-rows-[subgrid]' , 'grid-rows-subgrid' ] ,
673
+
674
+ // Only 50-200% (inclusive) are valid:
675
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/font-stretch#percentage
676
+ [ 'font-stretch-[50%]' , 'font-stretch-50%' ] ,
677
+ [ 'font-stretch-[50.5%]' , 'font-stretch-[50.5%]' ] ,
678
+ [ 'font-stretch-[201%]' , 'font-stretch-[201%]' ] ,
679
+ [ 'font-stretch-[49%]' , 'font-stretch-[49%]' ] ,
680
+ // Should stay as-is
681
+ [ 'font-stretch-[1/2]' , 'font-stretch-[1/2]' ] ,
682
+
683
+ // Bare value with % is valid for these utilities
684
+ [ 'from-[28%]' , 'from-28%' ] ,
685
+ [ 'via-[28%]' , 'via-28%' ] ,
686
+ [ 'to-[28%]' , 'to-28%' ] ,
687
+ [ 'from-[28.5%]' , 'from-[28.5%]' ] ,
688
+ [ 'via-[28.5%]' , 'via-[28.5%]' ] ,
689
+ [ 'to-[28.5%]' , 'to-[28.5%]' ] ,
690
+
691
+ // This test in itself is a bit flawed because `text-[1/2]` currently
692
+ // generates something. Converting it to `text-1/2` doesn't produce anything.
693
+ [ 'text-[1/2]' , 'text-[1/2]' ] ,
694
+
695
+ // Leading is special, because `leading-[123]` is the direct value of 123, but
696
+ // `leading-123` maps to `calc(--spacing(123))`.
697
+ [ 'leading-[123]' , 'leading-[123]' ] ,
698
+
699
+ [ 'data-[selected]:flex' , 'data-selected:flex' ] ,
700
+ [ 'data-[foo=bar]:flex' , 'data-[foo=bar]:flex' ] ,
701
+
702
+ [ 'supports-[gap]:flex' , 'supports-gap:flex' ] ,
703
+ [ 'supports-[display:grid]:flex' , 'supports-[display:grid]:flex' ] ,
704
+
705
+ [ 'group-data-[selected]:flex' , 'group-data-selected:flex' ] ,
706
+ [ 'group-data-[foo=bar]:flex' , 'group-data-[foo=bar]:flex' ] ,
707
+ [ 'group-has-data-[selected]:flex' , 'group-has-data-selected:flex' ] ,
708
+
709
+ [ 'aria-[selected]:flex' , 'aria-[selected]:flex' ] ,
710
+ [ 'aria-[selected="true"]:flex' , 'aria-selected:flex' ] ,
711
+ [ 'aria-[selected*="true"]:flex' , 'aria-[selected*="true"]:flex' ] ,
712
+
713
+ [ 'group-aria-[selected]:flex' , 'group-aria-[selected]:flex' ] ,
714
+ [ 'group-aria-[selected="true"]:flex' , 'group-aria-selected:flex' ] ,
715
+ [ 'group-has-aria-[selected]:flex' , 'group-has-aria-[selected]:flex' ] ,
716
+
717
+ [ 'max-lg:hover:data-[selected]:flex!' , 'max-lg:hover:data-selected:flex!' ] ,
718
+ [
719
+ 'data-[selected]:aria-[selected="true"]:aspect-[12/34]' ,
720
+ 'data-selected:aria-selected:aspect-12/34' ,
721
+ ] ,
722
+ ] ) ( testName , async ( candidate , expected ) => {
723
+ let input = css `
724
+ @import 'tailwindcss' ;
725
+ `
726
+ await expectCanonicalization ( input , candidate , expected )
727
+ } )
728
+ } )
663
729
} )
664
730
665
731
describe ( 'theme to var' , ( ) => {
0 commit comments