Skip to content

Commit 27d0aa6

Browse files
committed
ensure we normalize the arbitrary modifiers
This applies the same rules as arbitrary values. The `_` can be used in place of a space. If you _do_ want an underscore, you can escape it with `\_` (`\\_` in JavaScript).
1 parent 5b2c180 commit 27d0aa6

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/util/pluginUtils.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,7 @@ export function parseColorFormat(value) {
115115
}
116116

117117
function unwrapArbitraryModifier(modifier) {
118-
modifier = modifier.slice(1, -1)
119-
if (modifier.startsWith('--')) {
120-
modifier = `var(${modifier})`
121-
}
122-
return modifier
118+
return normalize(modifier.slice(1, -1))
123119
}
124120

125121
export function asColor(modifier, options = {}, { tailwindConfig = {} } = {}) {

tests/arbitrary-values.test.js

+15
Original file line numberDiff line numberDiff line change
@@ -637,4 +637,19 @@ crosscheck(({ stable, oxide }) => {
637637
`)
638638
})
639639
})
640+
641+
it('should support underscores in arbitrary modifiers', () => {
642+
let config = {
643+
content: [{ raw: html`<div class="text-lg/[calc(50px_*_2)]"></div>` }],
644+
}
645+
646+
return run('@tailwind utilities', config).then((result) => {
647+
return expect(result.css).toMatchFormattedCss(css`
648+
.text-lg\/\[calc\(50px_\*_2\)\] {
649+
font-size: 1.125rem;
650+
line-height: calc(50px * 2);
651+
}
652+
`)
653+
})
654+
})
640655
})

0 commit comments

Comments
 (0)