8000 Normalize arbitrary modifiers by RobinMalfait · Pull Request #11057 · tailwindlabs/tailwindcss · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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).
  • Loading branch information
RobinMalfait committed Apr 21, 2023
commit 727c15dfbbe02feb8f371d4f7c0fca19c9468519
6 changes: 1 addition & 5 deletions src/util/pluginUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,7 @@ export function parseColorFormat(value) {
}

function unwrapArbitraryModifier(modifier) {
modifier = modifier.slice(1, -1)
if (modifier.startsWith('--')) {
modifier = `var(${modifier})`
}
return modifier
return normalize(modifier.slice(1, -1))
}

export function asColor(modifier, options = {}, { tailwindConfig = {} } = {}) {
Expand Down
15 changes: 15 additions & 0 deletions tests/arbitrary-values.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -637,4 +637,19 @@ crosscheck(({ stable, oxide }) => {
`)
})
})

it('should support underscores in arbitrary modifiers', () => {
let config = {
content: [{ raw: html`<div class="text-lg/[calc(50px_*_2)]"></div>` }],
}

return run('@tailwind utilities', config).then((result) => {
return expect(result.css).toMatchFormattedCss(css`
.text-lg\/\[calc\(50px_\*_2\)\] {
font-size: 1.125rem;
line-height: calc(50px * 2);
}
`)
})
})
})