Skip to content

Commit

Permalink
Fixed edge case for none in grid-template
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianRappl committed Apr 21, 2021
1 parent ee42ad7 commit 7c24091
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/AngleSharp.Css.Tests/Declarations/CssGridProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -768,5 +768,13 @@ public void CssRuleWithOnlyGridTemplateAreasLegal_Issue27()
var text = rule.CssText;
Assert.AreEqual(snippet, text);
}

[Test]
public void CssGridTemplateLonghands_Issue68()
{
var snippet = "grid-template-areas: none; grid-template-columns: none; grid-template-rows: none";
var style = ParseDeclarations(snippet);
Assert.AreEqual("grid-template: none", style.CssText);
}
}
}
8 changes: 6 additions & 2 deletions src/AngleSharp.Css/Values/Composites/CssGridTemplateValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ public String CssText
var rows = String.Empty;
var cols = _columns?.CssText;

if (_areas != null)
if (_areas is Constant<object> || _columns is Constant<object> || _rows is Constant<object>)
{
return CssKeywords.None;
}
else if (_areas != null)
{
var areas = ((CssTupleValue)_areas).Items;
var rowItems = ((CssTupleValue)_rows).Items;
Expand Down Expand Up @@ -89,7 +93,7 @@ public String CssText

if (!String.IsNullOrEmpty(cols))
{
return String.Concat(rows, " / ",cols);
return String.Concat(rows, " / ", cols);
}

return rows;
Expand Down

0 comments on commit 7c24091

Please sign in to comment.