Skip to content

Commit

Permalink
Fixed usage of skew() with single argument AngleSharp#101
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianRappl committed Jun 2, 2022
1 parent 46b9c9a commit fc0ad92
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Released on Tuesday, May 31 2022.
- Dropped .NET Framework 4.6
- Updated to use AngleSharp 0.17
- Fixed casing issue with color, timing, and gradient functions (#109)
- Fixed parsing of `skew` (#101)
- Fixed shorthand properties using `inherit` being omitted (#100)
- Added support for `conic-gradient` (#101)

Expand Down
12 changes: 12 additions & 0 deletions src/AngleSharp.Css.Tests/Declarations/CssTransformProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,18 @@ public void CssTransformSkewYLegal()
Assert.AreEqual("skewY(1.07rad)", property.Value);
}

[Test]
public void CssTransformSkewLegal_Issue101()
{
var snippet = "transform: skew(20deg) ";
var property = ParseDeclaration(snippet);
Assert.AreEqual("transform", property.Name);
Assert.IsFalse(property.IsImportant);
Assert.IsFalse(property.IsInherited);
Assert.IsTrue(property.HasValue);
Assert.AreEqual("skew(20deg)", property.Value);
}

[Test]
public void CssTransformMultipleLegal()
{
Expand Down
21 changes: 15 additions & 6 deletions src/AngleSharp.Css/Parser/Micro/TransformParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,26 @@ public static ICssTransformFunctionValue ParseTransform(this StringSource source
/// </summary>
private static CssSkewValue ParseSkew2d(StringSource source)
{
var x = source.ParseAngleOrCalc();
ICssValue x = source.ParseAngleOrCalc();
ICssValue y = Angle.Zero;
var c = source.SkipGetSkip();
var y = source.ParseAngleOrCalc();
var f = source.SkipGetSkip();

if (x != null && y != null && c == Symbols.Comma && f == Symbols.RoundBracketClose)
if (x == null)
{
return new CssSkewValue(x, y);
return null;
}

return null;
if (c == Symbols.Comma) {
y = source.ParseAngleOrCalc();
c = source.SkipGetSkip();
}

if (c != Symbols.RoundBracketClose)
{
return null;
}

return new CssSkewValue(x, y);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/AngleSharp.Css/Values/Functions/CssSkewValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public String CssText
{
args = _beta.CssText;
}
else if (_beta != null)
else if (_beta != null && _beta.CssText != "0rad")
{
args = String.Concat(args, ", ", _beta.CssText);
}
Expand Down

0 comments on commit fc0ad92

Please sign in to comment.