Skip to content

Commit 9bb45cd

Browse files
authored
Normalize arbitrary modifiers (#11057)
* 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). * update changelog
1 parent 0e2b451 commit 9bb45cd

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- Honor default `to` position of gradient when using implicit transparent colors ([#11002](https://github.com/tailwindlabs/tailwindcss/pull/11002))
1515
- Ensure `@tailwindcss/oxide` doesn't leak in the stable engine ([#10988](https://github.com/tailwindlabs/tailwindcss/pull/10988))
1616
- Ensure multiple `theme(spacing[5])` calls with bracket notation in arbitrary properties work ([#11039](https://github.com/tailwindlabs/tailwindcss/pull/11039))
17+
- Normalize arbitrary modifiers ([#11057](https://github.com/tailwindlabs/tailwindcss/pull/11057))
1718

1819
## [3.3.1] - 2023-03-30
1920

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)