Skip to content

Commit

Permalink
fixes bug trullock#384 do not strip fr unit when reducing zeros; brow…
Browse files Browse the repository at this point in the history
…sers don't animate changes to the grid-template-rows or grid-template-columns property when the unit changes from 1fr to 0.
  • Loading branch information
Jason Moore committed Apr 3, 2024
1 parent fd2b43f commit c35eb8c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/NUglify.Tests/Css/Bugs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,12 @@ public void Bug379()
}
").Code);
}

[Test]
public void Bug384()
{
var uglifyResult = Uglify.Css("grid-template-rows: 0fr 0px 0% 0em;");
Assert.AreEqual("grid-template-rows: 0fr 0 0% 0;", uglifyResult.Code);
}
}
}
5 changes: 4 additions & 1 deletion src/NUglify/Css/CssScanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,6 @@ CssToken ScanNum(bool reduceZeros)
case "VM": // viewport width or height, whichever is smaller of the two (use VMIN)
case "VMIN": // minimum of the viewport's height and width
case "VMAX": // maximum of the viewport's height and width
case "FR": // fraction of available space
case "GR": // grid unit
case "GD": // text grid unit
tokenType = TokenType.RelativeLength;
Expand Down Expand Up @@ -1128,6 +1127,10 @@ CssToken ScanNum(bool reduceZeros)
case "ST": // semitones
tokenType = TokenType.Speech;
break;
// browsers do not animate grid-template-* if the fr unit is stripped
case "FR": // fraction of available space
tokenType = TokenType.Dimension;
break;
}

// if the number is zero, it really doesn't matter what the dimensions are so we can remove it
Expand Down

0 comments on commit c35eb8c

Please sign in to comment.