Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/AngleSharp.Css.Tests/Declarations/CssFlexProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,36 @@ public void CssFlexShorthandGrowAndShrinkLegal()
Assert.AreEqual("1 2", property.Value);
}

[Test]
public void CssFlexShorthandWithZeroPercentBasisLegal()
{
var snippet = "flex: 1 1 0%";
var property = ParseDeclaration(snippet);
Assert.AreEqual("flex", property.Name);
Assert.IsTrue(property.HasValue);
Assert.AreEqual("1 1 0%", property.Value);
}

[Test]
public void CssFlexBasisZeroPercentLegal()
{
var snippet = "flex-basis: 0%";
var property = ParseDeclaration(snippet);
Assert.AreEqual("flex-basis", property.Name);
Assert.IsTrue(property.HasValue);
Assert.AreEqual("0%", property.Value);
}

[Test]
public void CssFlexBasisZeroPxSerializesWithoutUnit()
{
var snippet = "flex-basis: 0px";
var property = ParseDeclaration(snippet);
Assert.AreEqual("flex-basis", property.Name);
Assert.IsTrue(property.HasValue);
Assert.AreEqual("0", property.Value);
}

[Test]
public void CssFlexWrapLegal()
{
Expand Down
2 changes: 1 addition & 1 deletion src/AngleSharp.Css.Tests/Declarations/CssObjectSizing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void CssObjectPositionLeft30Legal()
Assert.IsTrue(property.IsAnimatable);
Assert.IsFalse(property.IsInherited);
Assert.IsTrue(property.HasValue);
Assert.AreEqual("0 30px", property.Value);
Assert.AreEqual("0% 30px", property.Value);
}
}
}
8 changes: 4 additions & 4 deletions src/AngleSharp.Css.Tests/Declarations/CssTransformProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public void CssTransformOriginYOffsetXKeywordLegal()
Assert.IsFalse(property.IsImportant);
Assert.IsFalse(property.IsInherited);
Assert.IsTrue(property.HasValue);
Assert.AreEqual("0 2px", property.Value);
Assert.AreEqual("0% 2px", property.Value);
}

[Test]
Expand All @@ -242,7 +242,7 @@ public void CssTransformOriginXKeywordYOffsetLegal()
Assert.IsFalse(property.IsImportant);
Assert.IsFalse(property.IsInherited);
Assert.IsTrue(property.HasValue);
Assert.AreEqual("0 2px", property.Value);
Assert.AreEqual("0% 2px", property.Value);
}

[Test]
Expand Down Expand Up @@ -290,7 +290,7 @@ public void CssTransformOriginYXKeywordZLegal()
Assert.IsFalse(property.IsImportant);
Assert.IsFalse(property.IsInherited);
Assert.IsTrue(property.HasValue);
Assert.AreEqual("0 2px 10px", property.Value);
Assert.AreEqual("0% 2px 10px", property.Value);
}

[Test]
Expand All @@ -302,7 +302,7 @@ public void CssTransformOriginXKeywordYZLegal()
Assert.IsFalse(property.IsImportant);
Assert.IsFalse(property.IsInherited);
Assert.IsTrue(property.HasValue);
Assert.AreEqual("0 5px -3px", property.Value);
Assert.AreEqual("0% 5px -3px", property.Value);
}

[Test]
Expand Down
4 changes: 3 additions & 1 deletion src/AngleSharp.Css/Values/Primitives/CssLengthValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ public String CssText
}
else
{
var unit = _value == 0.0 ? String.Empty : UnitString;
// Per CSS spec, 0 is valid without a unit for lengths,
// but 0% is a percentage (relative to context) and must keep its unit.
var unit = _value == 0.0 && _unit != Unit.Percent ? String.Empty : UnitString;
var val = _value.CssStringify();
return String.Concat(val, unit);
}
Expand Down
Loading