File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,18 @@ function isArbitraryValue(input) {
8888function splitUtilityModifier ( modifier ) {
8989 let slashIdx = modifier . lastIndexOf ( '/' )
9090
91+ // If the `/` is inside an arbitrary, we want to find the previous one if any
92+ // This logic probably isn't perfect but it should work for most cases
93+ let arbitraryStartIdx = modifier . lastIndexOf ( '[' , slashIdx )
94+ let arbitraryEndIdx = modifier . indexOf ( ']' , slashIdx )
95+
96+ // Backtrack to the previous `/` if the one we found was inside an arbitrary
97+ if ( arbitraryStartIdx !== - 1 && arbitraryEndIdx !== - 1 ) {
98+ if ( arbitraryStartIdx < slashIdx && slashIdx < arbitraryEndIdx ) {
99+ slashIdx = modifier . lastIndexOf ( '/' , arbitraryStartIdx )
100+ }
101+ }
102+
91103 if ( slashIdx === - 1 || slashIdx === modifier . length - 1 ) {
92104 return [ modifier , undefined ]
93105 }
Original file line number Diff line number Diff line change @@ -652,6 +652,21 @@ crosscheck(({ stable, oxide }) => {
652652 ` )
653653 } )
654654 } )
655+
656+ it ( 'should support slashes in arbitrary modifiers' , ( ) => {
657+ let config = {
658+ content : [ { raw : html `<div class= "text-lg/[calc(50px/2)]" > </ div> ` } ] ,
659+ }
660+
661+ return run ( '@tailwind utilities' , config ) . then ( ( result ) => {
662+ return expect ( result . css ) . toMatchFormattedCss ( css `
663+ .text-lg\/\[calc\(50px\/2 \)\] {
664+ font-size : 1.125rem ;
665+ line-height : calc (50px / 2 );
666+ }
667+ ` )
668+ } )
669+ } )
655670} )
656671
657672it ( 'should not insert spaces around operators inside `env()`' , ( ) => {
You can’t perform that action at this time.
0 commit comments