Skip to content

Commit

Permalink
ensure font-stretch-[50.5%] stays as an arbitrary value
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinMalfait committed Oct 15, 2024
1 parent ab397ab commit 0d31180
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ test.each([
// Only 50-200% (inclusive) are valid:
// https://developer.mozilla.org/en-US/docs/Web/CSS/font-stretch#percentage
['font-stretch-[50%]', 'font-stretch-50%'],
['font-stretch-[50.5%]', 'font-stretch-[50.5%]'],
['font-stretch-[201%]', 'font-stretch-[201%]'],
['font-stretch-[49%]', 'font-stretch-[49%]'],
// Should stay as-is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export function arbitraryValueToBareValue(
clone.value.dataType === null &&
clone.root === 'font-stretch'
) {
if (clone.value.value.endsWith('%')) {
let percentage = parseFloat(clone.value.value)
if (clone.value.value.endsWith('%') && isPositiveInteger(clone.value.value.slice(0, -1))) {
let percentage = parseInt(clone.value.value)
if (percentage >= 50 && percentage <= 200) {
changed = true
clone.value = {
Expand Down

0 comments on commit 0d31180

Please sign in to comment.