Skip to content

Commit fc0ad92

Browse files
committed
Fixed usage of skew() with single argument #101
1 parent 46b9c9a commit fc0ad92

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Released on Tuesday, May 31 2022.
55
- Dropped .NET Framework 4.6
66
- Updated to use AngleSharp 0.17
77
- Fixed casing issue with color, timing, and gradient functions (#109)
8+
- Fixed parsing of `skew` (#101)
89
- Fixed shorthand properties using `inherit` being omitted (#100)
910
- Added support for `conic-gradient` (#101)
1011

src/AngleSharp.Css.Tests/Declarations/CssTransformProperty.cs

+12
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,18 @@ public void CssTransformSkewYLegal()
461461
Assert.AreEqual("skewY(1.07rad)", property.Value);
462462
}
463463

464+
[Test]
465+
public void CssTransformSkewLegal_Issue101()
466+
{
467+
var snippet = "transform: skew(20deg) ";
468+
var property = ParseDeclaration(snippet);
469+
Assert.AreEqual("transform", property.Name);
470+
Assert.IsFalse(property.IsImportant);
471+
Assert.IsFalse(property.IsInherited);
472+
Assert.IsTrue(property.HasValue);
473+
Assert.AreEqual("skew(20deg)", property.Value);
474+
}
475+
464476
[Test]
465477
public void CssTransformMultipleLegal()
466478
{

src/AngleSharp.Css/Parser/Micro/TransformParser.cs

+15-6
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,26 @@ public static ICssTransformFunctionValue ParseTransform(this StringSource source
6262
/// </summary>
6363
private static CssSkewValue ParseSkew2d(StringSource source)
6464
{
65-
var x = source.ParseAngleOrCalc();
65+
ICssValue x = source.ParseAngleOrCalc();
66+
ICssValue y = Angle.Zero;
6667
var c = source.SkipGetSkip();
67-
var y = source.ParseAngleOrCalc();
68-
var f = source.SkipGetSkip();
6968

70-
if (x != null && y != null && c == Symbols.Comma && f == Symbols.RoundBracketClose)
69+
if (x == null)
7170
{
72-
return new CssSkewValue(x, y);
71+
return null;
7372
}
7473

75-
return null;
74+
if (c == Symbols.Comma) {
75+
y = source.ParseAngleOrCalc();
76+
c = source.SkipGetSkip();
77+
}
78+
79+
if (c != Symbols.RoundBracketClose)
80+
{
81+
return null;
82+
}
83+
84+
return new CssSkewValue(x, y);
7685
}
7786

7887
/// <summary>

src/AngleSharp.Css/Values/Functions/CssSkewValue.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public String CssText
7676
{
7777
args = _beta.CssText;
7878
}
79-
else if (_beta != null)
79+
else if (_beta != null && _beta.CssText != "0rad")
8080
{
8181
args = String.Concat(args, ", ", _beta.CssText);
8282
}

0 commit comments

Comments
 (0)