Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianRappl committed Nov 4, 2021
1 parent 382b4bf commit 715f038
Show file tree
Hide file tree
Showing 12 changed files with 144 additions and 15 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 0.16.2

Released on Thursday, November 4 2021.

- Fixed issue with unbalanced grid areas and rows (#82)
- Fixed small numbers to be transformed into negative exponentials (#80)

# 0.16.1

Released on Wednesday, August 11 2021.
Expand Down
12 changes: 12 additions & 0 deletions src/AngleSharp.Css.Tests/Declarations/CssMarginProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ public void CssMarginLeftLengthLegal()
Assert.AreEqual("15px", property.Value);
}

[Test]
public void CssMarginLeftTinyValue_Issue80()
{
var snippet = "margin-left: 0.00001px";
var property = ParseDeclaration(snippet);
Assert.AreEqual("margin-left", property.Name);
Assert.IsFalse(property.IsImportant);
Assert.IsFalse(property.IsInherited);
Assert.IsTrue(property.HasValue);
Assert.AreEqual("0.00001px", property.Value);
}

[Test]
public void CssMarginLeftInitialLegal()
{
Expand Down
105 changes: 105 additions & 0 deletions src/AngleSharp.Css.Tests/Parsing/StyleSheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,110 @@ public async Task ParseEmptySheet_Issue42()
var sheet = await parser.ParseStyleSheetAsync(sheetCode);
Assert.IsNotNull(sheet);
}

[Test]
public async Task ParseStyleSheetAndBack_Issue82()
{
var css = @"
.root {
position: absolute;
top: 0;
left: 0;
width: calc(100% - 10px);
height: calc(100% - 10px);
padding: 5px;
}
.container {
width: 100%;
height: 100%;
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-rows: 240px calc(100% - 360px) 100px;
grid-template-areas: 'header info' 'quantity info' 'footerOk footerCancel';
row-gap: 10px;
font-size: 26px;
}
.destination {
grid-area: header;
width: calc(100% - 20px);
height: calc(100% - 20px);
margin: 10px;
display: grid;
grid-template-columns: auto auto auto;
grid-template-rows: 150px 50px;
grid-template-areas:
""sourcerp image destrp""
""sourcele image destle"";
}
.quantitygrid {
width: 100%;
height: 100%;
display: grid;
grid-template-columns: auto auto auto;
grid-template-rows: 150px 100px;
grid-template-areas: 'minus number plus';
}
.headergrid {
width: 100%;
height: 100%;
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: 1fr 1fr;
grid-template-areas: 'sourceplace space destinationplace' 'sourcelc space destinationlc';
}
#info td + td {
font-size: 24px;
}
input {
animation-duration: 2s;
font-family: inherit;
background-color: white;
}
td {
padding: 5px;
}
paper-button {
padding: 0;
background-color: var(--kx-dark);
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
color: white;
/*font-weight: bolder;*/
}
@keyframes errorAnimation {
0% {
background-color: white;
}
1% {
background-color: red;
}
100% {
background-color: white;
}
}
input:invalid {
color: red;
}
";
var parser = new CssParser();
var formatter = new MinifyStyleFormatter();
var ss = await parser.ParseStyleSheetAsync(css);
var newCss = ss.ToCss(formatter);
Assert.IsNotNull(newCss);
}
}
}
12 changes: 12 additions & 0 deletions src/AngleSharp.Css/FormatValue.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace AngleSharp.Css
{
using System;
using System.Globalization;

static class FormatValue
{
public const String DoubleFixedPoint = "0.###################################################################################################################################################################################################################################################################################################################################################";

public static String CssStringify(this Double value) => value.ToString(DoubleFixedPoint, CultureInfo.InvariantCulture);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public String CssText

for (var i = 0; i < rowItems.Length; i++)
{
var area = areas[i];
var area = areas.Length > i ? areas[i] : null;
var item = rowItems[i] as CssTupleValue;

if (item != null && area != null)
Expand Down
4 changes: 1 addition & 3 deletions src/AngleSharp.Css/Values/Primitives/Angle.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
namespace AngleSharp.Css.Values
{
using AngleSharp.Css.Dom;
using System;
using System.Globalization;

/// <summary>
/// Represents an angle object.
Expand Down Expand Up @@ -66,7 +64,7 @@ public Angle(Double value, Unit unit)
/// <summary>
/// Gets the CSS text representation.
/// </summary>
public String CssText => String.Concat(_value.ToString(CultureInfo.InvariantCulture), UnitString);
public String CssText => String.Concat(_value.CssStringify(), UnitString);

/// <summary>
/// Gets the value of the angle.
Expand Down
2 changes: 1 addition & 1 deletion src/AngleSharp.Css/Values/Primitives/Fraction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public Fraction(Double value, Unit unit)
/// <summary>
/// Gets the CSS text representation.
/// </summary>
public String CssText => String.Concat(_value.ToString(CultureInfo.InvariantCulture), UnitString);
public String CssText => String.Concat(_value.CssStringify(), UnitString);

/// <summary>
/// Gets the value of fraction.
Expand Down
3 changes: 1 addition & 2 deletions src/AngleSharp.Css/Values/Primitives/Frequency.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace AngleSharp.Css.Values
{
using System;
using System.Globalization;

/// <summary>
/// Represents a time value.
Expand Down Expand Up @@ -35,7 +34,7 @@ public Frequency(Double value, Unit unit)
/// <summary>
/// Gets the CSS text representation.
/// </summary>
public String CssText => String.Concat(_value.ToString(CultureInfo.InvariantCulture), UnitString);
public String CssText => String.Concat(_value.CssStringify(), UnitString);

/// <summary>
/// Gets the value of frequency.
Expand Down
3 changes: 1 addition & 2 deletions src/AngleSharp.Css/Values/Primitives/Length.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace AngleSharp.Css.Values
{
using System;
using System.Globalization;

/// <summary>
/// Represents an absolute length value.
Expand Down Expand Up @@ -99,7 +98,7 @@ public String CssText
else
{
var unit = _value == 0.0 ? String.Empty : UnitString;
var val = _value.ToString(CultureInfo.InvariantCulture);
var val = _value.CssStringify();
return String.Concat(val, unit);
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/AngleSharp.Css/Values/Primitives/Resolution.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace AngleSharp.Css.Values
{
using System;
using System.Globalization;

/// <summary>
/// Represents a resolution value.
Expand Down Expand Up @@ -35,7 +34,7 @@ public Resolution(Double value, Unit unit)
/// <summary>
/// Gets the CSS text representation.
/// </summary>
public String CssText => String.Concat(_value.ToString(CultureInfo.InvariantCulture), UnitString);
public String CssText => String.Concat(_value.CssStringify(), UnitString);

/// <summary>
/// Gets the value of resolution.
Expand Down
4 changes: 1 addition & 3 deletions src/AngleSharp.Css/Values/Primitives/Time.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
namespace AngleSharp.Css.Values
{
using AngleSharp.Css.Dom;
using System;
using System.Globalization;

/// <summary>
/// Represents a time value.
Expand Down Expand Up @@ -45,7 +43,7 @@ public Time(Double value, Unit unit)
/// <summary>
/// Gets the CSS text representation.
/// </summary>
public String CssText => String.Concat(_value.ToString(CultureInfo.InvariantCulture), UnitString);
public String CssText => String.Concat(_value.CssStringify(), UnitString);

/// <summary>
/// Gets the value of time.
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<PropertyGroup>
<Description>Extends the CSSOM from the core AngleSharp library.</Description>
<Product>AngleSharp.Css</Product>
<Version>0.16.1</Version>
<Version>0.16.2</Version>
</PropertyGroup>
</Project>

0 comments on commit 715f038

Please sign in to comment.