Skip to content

Commit 36acad0

Browse files
authored
Ensure font-stretch utilities only accepts positive integer bare values (tailwindlabs#14670)
This PR fixes an issue where bare values in the `font-stretch` utility such as `font-stretch-50.5%` compiled. But for bare values, we want these values to be positive integers only so that we don't have too many special characters. If you want to use `50.5%`, you can still use `font-stretch-[50.5%]` as a utility.
1 parent 782bc26 commit 36acad0

File tree

3 files changed

+3
-0
lines changed

3 files changed

+3
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3434
- Ensure `boxShadow` and `animation` theme keys in JS config files are accessible under `--shadow-*` and `--animate-*` using the `theme()` function ([#14642](https://github.com/tailwindlabs/tailwindcss/pull/14642))
3535
- Ensure all theme keys with new names are also accessible under their old names when using the `theme()` function with the legacy dot notation syntax ([#14642](https://github.com/tailwindlabs/tailwindcss/pull/14642))
3636
- Ensure `var(…)` can be used as the opacity value inside the `theme([path] / [modifier])` function ([#14653](https://github.com/tailwindlabs/tailwindcss/pull/14653))
37+
- Ensure `font-stretch` utilities only accepts positive integer bare values ([#14670](https://github.com/tailwindlabs/tailwindcss/pull/14670))
3738
- _Upgrade (experimental)_: Ensure CSS before a layer stays unlayered when running codemods ([#14596](https://github.com/tailwindlabs/tailwindcss/pull/14596))
3839
- _Upgrade (experimental)_: Resolve issues where some prefixed candidates were not properly migrated ([#14600](https://github.com/tailwindlabs/tailwindcss/pull/14600))
3940

packages/tailwindcss/src/utilities.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -11877,6 +11877,7 @@ test('font-stretch', async () => {
1187711877
'font-stretch-20%',
1187811878
'font-stretch-50',
1187911879
'font-stretch-400%',
11880+
'font-stretch-50.5%',
1188011881
'font-stretch-potato',
1188111882
'font-stretch-ultra-expanded/foo',
1188211883
'font-stretch-50%/foo',

packages/tailwindcss/src/utilities.ts

+1
Original file line numberDiff line numberDiff line change
@@ -3146,6 +3146,7 @@ export function createUtilities(theme: Theme) {
31463146
handleBareValue: ({ value }) => {
31473147
if (!value.endsWith('%')) return null
31483148
let num = Number(value.slice(0, -1))
3149+
if (!isPositiveInteger(num)) return null
31493150
// Only 50-200% (inclusive) are valid:
31503151
// https://developer.mozilla.org/en-US/docs/Web/CSS/font-stretch#percentage
31513152
if (Number.isNaN(num) || num < 50 || num > 200) return null

0 commit comments

Comments
 (0)