Skip to content

Commit 0d31180

Browse files
committed
ensure font-stretch-[50.5%] stays as an arbitrary value
1 parent ab397ab commit 0d31180

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

packages/@tailwindcss-upgrade/src/template/codemods/arbitrary-value-to-bare-value.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ test.each([
1111
// Only 50-200% (inclusive) are valid:
1212
// https://developer.mozilla.org/en-US/docs/Web/CSS/font-stretch#percentage
1313
['font-stretch-[50%]', 'font-stretch-50%'],
14+
['font-stretch-[50.5%]', 'font-stretch-[50.5%]'],
1415
['font-stretch-[201%]', 'font-stretch-[201%]'],
1516
['font-stretch-[49%]', 'font-stretch-[49%]'],
1617
// Should stay as-is

packages/@tailwindcss-upgrade/src/template/codemods/arbitrary-value-to-bare-value.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ export function arbitraryValueToBareValue(
2121
clone.value.dataType === null &&
2222
clone.root === 'font-stretch'
2323
) {
24-
if (clone.value.value.endsWith('%')) {
25-
let percentage = parseFloat(clone.value.value)
24+
if (clone.value.value.endsWith('%') && isPositiveInteger(clone.value.value.slice(0, -1))) {
25+
let percentage = parseInt(clone.value.value)
2626
if (percentage >= 50 && percentage <= 200) {
2727
changed = true
2828
clone.value = {

0 commit comments

Comments
 (0)